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