Service Notifications: Support forwarding
This commit is contained in:
parent
b3f5ebffcb
commit
6390e45c51
@ -16,6 +16,7 @@ import {
|
||||
import { LoadMoreDirection } from '../../../types';
|
||||
|
||||
import { MAX_MEDIA_FILES_FOR_ALBUM, MESSAGE_LIST_SLICE, SERVICE_NOTIFICATIONS_USER_ID } from '../../../config';
|
||||
import { IS_IOS } from '../../../util/environment';
|
||||
import { callApi, cancelApiProgress } from '../../../api/gramjs';
|
||||
import { areSortedArraysIntersecting, buildCollectionByKey, split } from '../../../util/iteratees';
|
||||
import {
|
||||
@ -54,7 +55,7 @@ import {
|
||||
selectFirstUnreadId,
|
||||
} from '../../selectors';
|
||||
import { debounce, rafPromise } from '../../../util/schedulers';
|
||||
import { IS_IOS } from '../../../util/environment';
|
||||
import { isServiceNotificationMessage } from '../../helpers';
|
||||
|
||||
const uploadProgressCallbacks = new Map<number, ApiOnProgress>();
|
||||
|
||||
@ -553,9 +554,39 @@ addReducer('forwardMessages', (global) => {
|
||||
.map((id) => selectChatMessage(global, fromChatId, id)).filter<ApiMessage>(Boolean as any)
|
||||
: undefined;
|
||||
|
||||
if (fromChat && toChat && messages && messages.length) {
|
||||
void forwardMessages(fromChat, toChat, messages);
|
||||
if (!fromChat || !toChat || !messages) {
|
||||
return;
|
||||
}
|
||||
|
||||
const realMessages = messages.filter((m) => !isServiceNotificationMessage(m));
|
||||
if (realMessages.length) {
|
||||
void callApi('forwardMessages', {
|
||||
fromChat,
|
||||
toChat,
|
||||
messages: realMessages,
|
||||
serverTimeOffset: getGlobal().serverTimeOffset,
|
||||
});
|
||||
}
|
||||
|
||||
messages
|
||||
.filter((m) => isServiceNotificationMessage(m))
|
||||
.forEach((message) => {
|
||||
const { text, entities } = message.content.text || {};
|
||||
const { sticker, poll } = message.content;
|
||||
|
||||
void sendMessage({
|
||||
chat: toChat,
|
||||
text,
|
||||
entities,
|
||||
sticker,
|
||||
poll,
|
||||
});
|
||||
});
|
||||
|
||||
setGlobal({
|
||||
...getGlobal(),
|
||||
forwardMessages: {},
|
||||
});
|
||||
});
|
||||
|
||||
addReducer('loadScheduledHistory', (global, actions, payload) => {
|
||||
@ -781,13 +812,13 @@ function getViewportSlice(
|
||||
|
||||
async function sendMessage(params: {
|
||||
chat: ApiChat;
|
||||
text: string;
|
||||
entities: ApiMessageEntity[];
|
||||
replyingTo: number;
|
||||
attachment: ApiAttachment;
|
||||
sticker: ApiSticker;
|
||||
gif: ApiVideo;
|
||||
poll: ApiNewPoll;
|
||||
text?: string;
|
||||
entities?: ApiMessageEntity[];
|
||||
replyingTo?: number;
|
||||
attachment?: ApiAttachment;
|
||||
sticker?: ApiSticker;
|
||||
gif?: ApiVideo;
|
||||
poll?: ApiNewPoll;
|
||||
serverTimeOffset?: number;
|
||||
}) {
|
||||
let localId: number | undefined;
|
||||
@ -834,24 +865,6 @@ async function sendMessage(params: {
|
||||
}
|
||||
}
|
||||
|
||||
function forwardMessages(
|
||||
fromChat: ApiChat,
|
||||
toChat: ApiChat,
|
||||
messages: ApiMessage[],
|
||||
) {
|
||||
callApi('forwardMessages', {
|
||||
fromChat,
|
||||
toChat,
|
||||
messages,
|
||||
serverTimeOffset: getGlobal().serverTimeOffset,
|
||||
});
|
||||
|
||||
setGlobal({
|
||||
...getGlobal(),
|
||||
forwardMessages: {},
|
||||
});
|
||||
}
|
||||
|
||||
async function loadPollOptionResults(
|
||||
chat: ApiChat,
|
||||
messageId: number,
|
||||
|
||||
@ -409,7 +409,7 @@ export function selectAllowedMessageActions(global: GlobalState, message: ApiMes
|
||||
|| (isChannel && (chat.isCreator || getHasAdminRight(chat, 'editMessages')))
|
||||
);
|
||||
|
||||
const canForward = !isLocal && !isServiceNotification && !isAction;
|
||||
const canForward = !isLocal && !isAction;
|
||||
|
||||
const hasSticker = Boolean(message.content.sticker);
|
||||
const hasFavoriteSticker = hasSticker && selectIsStickerFavorite(global, message.content.sticker!);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user