|
|
@ -58,6 +58,7 @@ import telegramMeWebManager from "../mtproto/telegramMeWebManager"; |
|
|
|
import { getMiddleware } from "../../helpers/middleware"; |
|
|
|
import { getMiddleware } from "../../helpers/middleware"; |
|
|
|
import assumeType from "../../helpers/assumeType"; |
|
|
|
import assumeType from "../../helpers/assumeType"; |
|
|
|
import appMessagesIdsManager from "./appMessagesIdsManager"; |
|
|
|
import appMessagesIdsManager from "./appMessagesIdsManager"; |
|
|
|
|
|
|
|
import type { MediaSize } from "../../helpers/mediaSizes"; |
|
|
|
|
|
|
|
|
|
|
|
//console.trace('include');
|
|
|
|
//console.trace('include');
|
|
|
|
// TODO: если удалить сообщение в непрогруженном диалоге, то при обновлении, из-за стейта, последнего сообщения в чатлисте не будет
|
|
|
|
// TODO: если удалить сообщение в непрогруженном диалоге, то при обновлении, из-за стейта, последнего сообщения в чатлисте не будет
|
|
|
@ -599,13 +600,17 @@ export class AppMessagesManager { |
|
|
|
width: number, |
|
|
|
width: number, |
|
|
|
height: number, |
|
|
|
height: number, |
|
|
|
objectURL: string, |
|
|
|
objectURL: string, |
|
|
|
thumbBlob: Blob, |
|
|
|
thumb: { |
|
|
|
thumbURL: string, |
|
|
|
blob: Blob, |
|
|
|
|
|
|
|
url: string, |
|
|
|
|
|
|
|
size: MediaSize |
|
|
|
|
|
|
|
}, |
|
|
|
duration: number, |
|
|
|
duration: number, |
|
|
|
background: true, |
|
|
|
background: true, |
|
|
|
silent: true, |
|
|
|
silent: true, |
|
|
|
clearDraft: true, |
|
|
|
clearDraft: true, |
|
|
|
scheduleDate: number, |
|
|
|
scheduleDate: number, |
|
|
|
|
|
|
|
noSound: boolean, |
|
|
|
|
|
|
|
|
|
|
|
waveform: Uint8Array, |
|
|
|
waveform: Uint8Array, |
|
|
|
}> = {}) { |
|
|
|
}> = {}) { |
|
|
@ -696,10 +701,11 @@ export class AppMessagesManager { |
|
|
|
apiFileName = 'video.mp4'; |
|
|
|
apiFileName = 'video.mp4'; |
|
|
|
actionName = 'sendMessageUploadVideoAction'; |
|
|
|
actionName = 'sendMessageUploadVideoAction'; |
|
|
|
|
|
|
|
|
|
|
|
let videoAttribute: DocumentAttribute.documentAttributeVideo = { |
|
|
|
const videoAttribute: DocumentAttribute.documentAttributeVideo = { |
|
|
|
_: 'documentAttributeVideo', |
|
|
|
_: 'documentAttributeVideo', |
|
|
|
pFlags: { |
|
|
|
pFlags: { |
|
|
|
round_message: options.isRoundMessage |
|
|
|
round_message: options.isRoundMessage, |
|
|
|
|
|
|
|
supports_streaming: true |
|
|
|
}, |
|
|
|
}, |
|
|
|
duration: options.duration, |
|
|
|
duration: options.duration, |
|
|
|
w: options.width, |
|
|
|
w: options.width, |
|
|
@ -707,6 +713,15 @@ export class AppMessagesManager { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
attributes.push(videoAttribute); |
|
|
|
attributes.push(videoAttribute); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// * must follow after video attribute
|
|
|
|
|
|
|
|
if(options.noSound && |
|
|
|
|
|
|
|
file.size > (10 * 1024) && |
|
|
|
|
|
|
|
file.size < (10 * 1024 * 1024)) { |
|
|
|
|
|
|
|
attributes.push({ |
|
|
|
|
|
|
|
_: 'documentAttributeAnimated' |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
attachType = 'document'; |
|
|
|
attachType = 'document'; |
|
|
|
apiFileName = 'document.' + fileType.split('/')[1]; |
|
|
|
apiFileName = 'document.' + fileType.split('/')[1]; |
|
|
@ -749,18 +764,18 @@ export class AppMessagesManager { |
|
|
|
size: file.size |
|
|
|
size: file.size |
|
|
|
}; |
|
|
|
}; |
|
|
|
} else if(attachType === 'video') { |
|
|
|
} else if(attachType === 'video') { |
|
|
|
if(options.thumbURL) { |
|
|
|
if(options.thumb) { |
|
|
|
thumb = { |
|
|
|
thumb = { |
|
|
|
_: 'photoSize', |
|
|
|
_: 'photoSize', |
|
|
|
w: options.width, |
|
|
|
w: options.thumb.size.width, |
|
|
|
h: options.height, |
|
|
|
h: options.thumb.size.height, |
|
|
|
type: 'full', |
|
|
|
type: 'local-thumb', |
|
|
|
size: options.thumbBlob.size |
|
|
|
size: options.thumb.blob.size |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const thumbCacheContext = appDownloadManager.getCacheContext(document, thumb.type); |
|
|
|
const thumbCacheContext = appDownloadManager.getCacheContext(document, thumb.type); |
|
|
|
thumbCacheContext.downloaded = thumb.size; |
|
|
|
thumbCacheContext.downloaded = thumb.size; |
|
|
|
thumbCacheContext.url = options.thumbURL; |
|
|
|
thumbCacheContext.url = options.thumb.url; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -800,7 +815,6 @@ export class AppMessagesManager { |
|
|
|
if(err.name === 'AbortError' && !uploaded) { |
|
|
|
if(err.name === 'AbortError' && !uploaded) { |
|
|
|
this.log('cancelling upload', media); |
|
|
|
this.log('cancelling upload', media); |
|
|
|
|
|
|
|
|
|
|
|
sentDeferred.reject(err); |
|
|
|
|
|
|
|
this.cancelPendingMessage(message.random_id); |
|
|
|
this.cancelPendingMessage(message.random_id); |
|
|
|
this.setTyping(peerId, {_: 'sendMessageCancelAction'}); |
|
|
|
this.setTyping(peerId, {_: 'sendMessageCancelAction'}); |
|
|
|
|
|
|
|
|
|
|
@ -867,12 +881,12 @@ export class AppMessagesManager { |
|
|
|
let thumbUploadPromise: typeof uploadPromise; |
|
|
|
let thumbUploadPromise: typeof uploadPromise; |
|
|
|
if(attachType === 'video' && options.objectURL) { |
|
|
|
if(attachType === 'video' && options.objectURL) { |
|
|
|
thumbUploadPromise = new Promise((resolve, reject) => { |
|
|
|
thumbUploadPromise = new Promise((resolve, reject) => { |
|
|
|
const blobPromise = options.thumbBlob ? Promise.resolve(options.thumbBlob) : createPosterForVideo(options.objectURL); |
|
|
|
const thumbPromise = options.thumb && options.thumb.blob ? Promise.resolve(options.thumb) : createPosterForVideo(options.objectURL); |
|
|
|
blobPromise.then(blob => { |
|
|
|
thumbPromise.then(thumb => { |
|
|
|
if(!blob) { |
|
|
|
if(!thumb) { |
|
|
|
resolve(null); |
|
|
|
resolve(null); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
appDownloadManager.upload(blob).then(resolve, reject); |
|
|
|
appDownloadManager.upload(thumb.blob).then(resolve, reject); |
|
|
|
} |
|
|
|
} |
|
|
|
}, reject); |
|
|
|
}, reject); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -3571,23 +3585,16 @@ export class AppMessagesManager { |
|
|
|
|
|
|
|
|
|
|
|
if(peerId < 0 && appPeersManager.isChannel(peerId)) { |
|
|
|
if(peerId < 0 && appPeersManager.isChannel(peerId)) { |
|
|
|
const channelId = -peerId; |
|
|
|
const channelId = -peerId; |
|
|
|
const channel = appChatsManager.getChat(channelId); |
|
|
|
const channel: Chat.channel = appChatsManager.getChat(channelId); |
|
|
|
if(!channel.pFlags.creator && !(channel.pFlags.editor && channel.pFlags.megagroup)) { |
|
|
|
if(!channel.pFlags.creator && !channel.admin_rights?.pFlags?.delete_messages) { |
|
|
|
const goodMsgIds: number[] = []; |
|
|
|
mids = mids.filter((mid) => { |
|
|
|
if(channel.pFlags.editor || channel.pFlags.megagroup) { |
|
|
|
const message = this.getMessageByPeer(peerId, mid); |
|
|
|
mids.forEach((msgId, i) => { |
|
|
|
return !!message.pFlags.out; |
|
|
|
const message = this.getMessageByPeer(peerId, mids[i]); |
|
|
|
|
|
|
|
if(message.pFlags.out) { |
|
|
|
|
|
|
|
goodMsgIds.push(msgId); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!goodMsgIds.length) { |
|
|
|
if(!mids.length) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mids = goodMsgIds; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
promise = apiManager.invokeApi('channels.deleteMessages', { |
|
|
|
promise = apiManager.invokeApi('channels.deleteMessages', { |
|
|
|