diff --git a/src/api/gramjs/apiBuilders/symbols.ts b/src/api/gramjs/apiBuilders/symbols.ts index 5eb2d7086..4c3f3aba1 100644 --- a/src/api/gramjs/apiBuilders/symbols.ts +++ b/src/api/gramjs/apiBuilders/symbols.ts @@ -8,19 +8,20 @@ import { buildApiThumbnailFromCached, buildApiThumbnailFromPath } from './common import localDb from '../localDb'; const LOTTIE_STICKER_MIME_TYPE = 'application/x-tgsticker'; -const GIF_STICKER_MIME_TYPE = 'video/webm'; +const VIDEO_STICKER_MIME_TYPE = 'video/webm'; export function buildStickerFromDocument(document: GramJs.TypeDocument): ApiSticker | undefined { if (document instanceof GramJs.DocumentEmpty) { return undefined; } + const { mimeType } = document; const stickerAttribute = document.attributes .find((attr: any): attr is GramJs.DocumentAttributeSticker => ( attr instanceof GramJs.DocumentAttributeSticker )); - const fileAttribute = (document.mimeType === LOTTIE_STICKER_MIME_TYPE || document.mimeType === GIF_STICKER_MIME_TYPE) + const fileAttribute = (mimeType === LOTTIE_STICKER_MIME_TYPE || mimeType === VIDEO_STICKER_MIME_TYPE) && document.attributes .find((attr: any): attr is GramJs.DocumentAttributeFilename => ( attr instanceof GramJs.DocumentAttributeFilename @@ -30,8 +31,8 @@ export function buildStickerFromDocument(document: GramJs.TypeDocument): ApiStic return undefined; } - const isLottie = document.mimeType === LOTTIE_STICKER_MIME_TYPE; - const isGif = document.mimeType === GIF_STICKER_MIME_TYPE; + const isLottie = mimeType === LOTTIE_STICKER_MIME_TYPE; + const isVideo = mimeType === VIDEO_STICKER_MIME_TYPE; const imageSizeAttribute = document.attributes .find((attr: any): attr is GramJs.DocumentAttributeImageSize => ( @@ -55,7 +56,7 @@ export function buildStickerFromDocument(document: GramJs.TypeDocument): ApiStic ); // eslint-disable-next-line no-restricted-globals - if (document.mimeType === GIF_STICKER_MIME_TYPE && !(self as any).isWebmSupported && !cachedThumb) { + if (mimeType === VIDEO_STICKER_MIME_TYPE && !(self as any).isWebmSupported && !cachedThumb) { const staticThumb = document.thumbs && document.thumbs.find( (s): s is GramJs.PhotoSize => s instanceof GramJs.PhotoSize, ); @@ -83,7 +84,7 @@ export function buildStickerFromDocument(document: GramJs.TypeDocument): ApiStic stickerSetAccessHash: stickerSetInfo && String(stickerSetInfo.accessHash), emoji, isLottie, - isGif, + isVideo, width, height, thumbnail, @@ -95,7 +96,7 @@ export function buildStickerSet(set: GramJs.StickerSet): ApiStickerSet { archived, animated, installedDate, - gifs, + videos, id, accessHash, title, @@ -107,7 +108,7 @@ export function buildStickerSet(set: GramJs.StickerSet): ApiStickerSet { return { archived, isLottie: animated, - isGifs: gifs, + isVideos: videos, installedDate, id: String(id), accessHash: String(accessHash), diff --git a/src/api/gramjs/gramjsBuilders/index.ts b/src/api/gramjs/gramjsBuilders/index.ts index 3dccbbbe6..29dbdc9df 100644 --- a/src/api/gramjs/gramjsBuilders/index.ts +++ b/src/api/gramjs/gramjsBuilders/index.ts @@ -420,6 +420,10 @@ export function buildInputReportReason(reason: ApiReportReason) { return new GramJs.InputReportReasonFake(); case 'geoIrrelevant': return new GramJs.InputReportReasonGeoIrrelevant(); + case 'illegalDrugs': + return new GramJs.InputReportReasonIllegalDrugs(); + case 'personalDetails': + return new GramJs.InputReportReasonPersonalDetails(); case 'other': return new GramJs.InputReportReasonOther(); } diff --git a/src/api/gramjs/methods/chats.ts b/src/api/gramjs/methods/chats.ts index 03cbf97c7..36cd23660 100644 --- a/src/api/gramjs/methods/chats.ts +++ b/src/api/gramjs/methods/chats.ts @@ -796,11 +796,23 @@ export async function toggleDialogUnread({ } } +export async function getChatByPhoneNumber(phoneNumber: string) { + const result = await invokeRequest(new GramJs.contacts.ResolvePhone({ + phone: phoneNumber, + })); + + return processResolvedPeer(result); +} + export async function getChatByUsername(username: string) { const result = await invokeRequest(new GramJs.contacts.ResolveUsername({ username, })); + return processResolvedPeer(result); +} + +function processResolvedPeer(result?: GramJs.contacts.TypeResolvedPeer) { if (!result) { return undefined; } diff --git a/src/api/gramjs/methods/index.ts b/src/api/gramjs/methods/index.ts index 31f920d0c..6bf936d11 100644 --- a/src/api/gramjs/methods/index.ts +++ b/src/api/gramjs/methods/index.ts @@ -15,6 +15,7 @@ export { getChatByUsername, togglePreHistoryHidden, updateChatDefaultBannedRights, updateChatMemberBannedRights, updateChatTitle, updateChatAbout, toggleSignatures, updateChatAdmin, fetchGroupsForDiscussion, setDiscussionGroup, migrateChat, openChatByInvite, fetchMembers, importChatInvite, addChatMembers, deleteChatMember, toggleIsProtected, + getChatByPhoneNumber, } from './chats'; export { diff --git a/src/api/types/messages.ts b/src/api/types/messages.ts index 5e230f9e3..7071573cd 100644 --- a/src/api/types/messages.ts +++ b/src/api/types/messages.ts @@ -26,7 +26,7 @@ export interface ApiSticker { stickerSetAccessHash?: string; emoji?: string; isLottie: boolean; - isGif: boolean; + isVideo: boolean; width?: number; height?: number; thumbnail?: ApiThumbnail; @@ -36,7 +36,7 @@ export interface ApiSticker { export interface ApiStickerSet { archived?: true; isLottie?: true; - isGifs?: true; + isVideos?: true; installedDate?: number; id: string; accessHash: string; @@ -382,7 +382,7 @@ export type ApiMessageSearchType = 'text' | 'media' | 'documents' | 'links' | 'a export type ApiGlobalMessageSearchType = 'text' | 'media' | 'documents' | 'links' | 'audio' | 'voice'; export type ApiReportReason = 'spam' | 'violence' | 'pornography' | 'childAbuse' -| 'copyright' | 'geoIrrelevant' | 'fake' | 'other'; +| 'copyright' | 'geoIrrelevant' | 'fake' | 'illegalDrugs' | 'personalDetails' | 'other'; export type ApiSendMessageAction = { type: 'cancel' | 'typing' | 'recordAudio' | 'chooseSticker'; diff --git a/src/components/common/ReportMessageModal.tsx b/src/components/common/ReportMessageModal.tsx index ebff72f8b..7627db886 100644 --- a/src/components/common/ReportMessageModal.tsx +++ b/src/components/common/ReportMessageModal.tsx @@ -55,6 +55,8 @@ const ReportMessageModal: FC = ({ { value: 'pornography', label: lang('lng_report_reason_pornography') }, { value: 'childAbuse', label: lang('lng_report_reason_child_abuse') }, { value: 'copyright', label: lang('ReportPeer.ReasonCopyright') }, + { value: 'illegalDrugs', label: 'Illegal Drugs' }, + { value: 'personalDetails', label: 'Personal Details' }, { value: 'other', label: lang('lng_report_reason_other') }, ]; diff --git a/src/components/common/StickerButton.tsx b/src/components/common/StickerButton.tsx index fa84b3032..4747c10ed 100644 --- a/src/components/common/StickerButton.tsx +++ b/src/components/common/StickerButton.tsx @@ -49,9 +49,9 @@ const StickerButton: FC = ({ const lottieData = useMedia(sticker.isLottie && localMediaHash, !shouldPlay, ApiMediaFormat.Lottie); const [isLottieLoaded, markLoaded, unmarkLoaded] = useFlag(Boolean(lottieData)); const canLottiePlay = isLottieLoaded && shouldPlay; - const isGif = sticker.isGif && IS_WEBM_SUPPORTED; - const gifBlobUrl = useMedia(isGif && localMediaHash, !shouldPlay, ApiMediaFormat.BlobUrl); - const canGifPlay = Boolean(isGif && gifBlobUrl && shouldPlay); + const isVideo = sticker.isVideo && IS_WEBM_SUPPORTED; + const videoBlobUrl = useMedia(isVideo && localMediaHash, !shouldPlay, ApiMediaFormat.BlobUrl); + const canVideoPlay = Boolean(isVideo && videoBlobUrl && shouldPlay); const { transitionClassNames: previewTransitionClassNames } = useShowTransition( Boolean(previewBlobUrl || canLottiePlay), @@ -68,15 +68,15 @@ const StickerButton: FC = ({ }, [unmarkLoaded, shouldPlay]); useEffect(() => { - if (!isGif || !ref.current) return; + if (!isVideo || !ref.current) return; const video = ref.current.querySelector('video'); if (!video) return; - if (canGifPlay) { + if (canVideoPlay) { safePlay(video); } else { video.pause(); } - }, [isGif, canGifPlay]); + }, [isVideo, canVideoPlay]); function handleClick() { if (onClick) { @@ -98,7 +98,7 @@ const StickerButton: FC = ({ className, ); - const style = (thumbDataUri && !canLottiePlay && !canGifPlay) ? `background-image: url('${thumbDataUri}');` : ''; + const style = (thumbDataUri && !canLottiePlay && !canVideoPlay) ? `background-image: url('${thumbDataUri}');` : ''; return (
= ({ onMouseDown={preventMessageInputBlurWithBubbling} onClick={handleClick} > - {!canLottiePlay && !canGifPlay && ( + {!canLottiePlay && !canVideoPlay && ( // eslint-disable-next-line jsx-a11y/alt-text )} - {isGif && ( + {isVideo && (