Support "Fake" and "Scam" badges (#1819)
This commit is contained in:
parent
8d9ae4b134
commit
97b778be22
@ -34,6 +34,8 @@ function buildApiChatFieldsFromPeerEntity(
|
|||||||
const avatarHash = ('photo' in peerEntity) && peerEntity.photo && buildAvatarHash(peerEntity.photo);
|
const avatarHash = ('photo' in peerEntity) && peerEntity.photo && buildAvatarHash(peerEntity.photo);
|
||||||
const isSignaturesShown = Boolean('signatures' in peerEntity && peerEntity.signatures);
|
const isSignaturesShown = Boolean('signatures' in peerEntity && peerEntity.signatures);
|
||||||
const hasPrivateLink = Boolean('hasLink' in peerEntity && peerEntity.hasLink);
|
const hasPrivateLink = Boolean('hasLink' in peerEntity && peerEntity.hasLink);
|
||||||
|
const isScam = Boolean('scam' in peerEntity && peerEntity.scam);
|
||||||
|
const isFake = Boolean('fake' in peerEntity && peerEntity.fake);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isMin,
|
isMin,
|
||||||
@ -60,6 +62,7 @@ function buildApiChatFieldsFromPeerEntity(
|
|||||||
...(('creator' in peerEntity) && { isCreator: peerEntity.creator }),
|
...(('creator' in peerEntity) && { isCreator: peerEntity.creator }),
|
||||||
...buildApiChatRestrictions(peerEntity),
|
...buildApiChatRestrictions(peerEntity),
|
||||||
...buildApiChatMigrationInfo(peerEntity),
|
...buildApiChatMigrationInfo(peerEntity),
|
||||||
|
fakeType: isScam ? 'scam' : (isFake ? 'fake' : undefined),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,7 +32,9 @@ export function buildApiUser(mtpUser: GramJs.TypeUser): ApiUser | undefined {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { id, firstName, lastName } = mtpUser;
|
const {
|
||||||
|
id, firstName, lastName, fake, scam,
|
||||||
|
} = mtpUser;
|
||||||
const avatarHash = mtpUser.photo instanceof GramJs.UserProfilePhoto
|
const avatarHash = mtpUser.photo instanceof GramJs.UserProfilePhoto
|
||||||
? String(mtpUser.photo.photoId)
|
? String(mtpUser.photo.photoId)
|
||||||
: undefined;
|
: undefined;
|
||||||
@ -41,6 +43,7 @@ export function buildApiUser(mtpUser: GramJs.TypeUser): ApiUser | undefined {
|
|||||||
return {
|
return {
|
||||||
id: buildApiPeerId(id, 'user'),
|
id: buildApiPeerId(id, 'user'),
|
||||||
isMin: Boolean(mtpUser.min),
|
isMin: Boolean(mtpUser.min),
|
||||||
|
fakeType: scam ? 'scam' : (fake ? 'fake' : undefined),
|
||||||
...(mtpUser.self && { isSelf: true }),
|
...(mtpUser.self && { isSelf: true }),
|
||||||
...(mtpUser.verified && { isVerified: true }),
|
...(mtpUser.verified && { isVerified: true }),
|
||||||
...((mtpUser.contact || mtpUser.mutualContact) && { isContact: true }),
|
...((mtpUser.contact || mtpUser.mutualContact) && { isContact: true }),
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { ApiMessage, ApiPhoto } from './messages';
|
import { ApiMessage, ApiPhoto } from './messages';
|
||||||
import { ApiBotCommand } from './bots';
|
import { ApiBotCommand } from './bots';
|
||||||
import { ApiChatInviteImporter } from './misc';
|
import { ApiChatInviteImporter } from './misc';
|
||||||
|
import { ApiFakeType } from './users';
|
||||||
|
|
||||||
type ApiChatType = (
|
type ApiChatType = (
|
||||||
'chatTypePrivate' | 'chatTypeSecret' |
|
'chatTypePrivate' | 'chatTypeSecret' |
|
||||||
@ -33,6 +34,7 @@ export interface ApiChat {
|
|||||||
photos?: ApiPhoto[];
|
photos?: ApiPhoto[];
|
||||||
draftDate?: number;
|
draftDate?: number;
|
||||||
isProtected?: boolean;
|
isProtected?: boolean;
|
||||||
|
fakeType?: ApiFakeType;
|
||||||
|
|
||||||
// Calls
|
// Calls
|
||||||
isCallActive?: boolean;
|
isCallActive?: boolean;
|
||||||
|
|||||||
@ -23,6 +23,7 @@ export interface ApiUser {
|
|||||||
maxId: string;
|
maxId: string;
|
||||||
isFullyLoaded: boolean;
|
isFullyLoaded: boolean;
|
||||||
};
|
};
|
||||||
|
fakeType?: ApiFakeType;
|
||||||
|
|
||||||
// Obtained from GetFullUser / UserFullInfo
|
// Obtained from GetFullUser / UserFullInfo
|
||||||
fullInfo?: ApiUserFullInfo;
|
fullInfo?: ApiUserFullInfo;
|
||||||
@ -37,6 +38,8 @@ export interface ApiUserFullInfo {
|
|||||||
botCommands?: ApiBotCommand[];
|
botCommands?: ApiBotCommand[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ApiFakeType = 'fake' | 'scam';
|
||||||
|
|
||||||
export type ApiUserType = 'userTypeBot' | 'userTypeRegular' | 'userTypeDeleted' | 'userTypeUnknown';
|
export type ApiUserType = 'userTypeBot' | 'userTypeRegular' | 'userTypeDeleted' | 'userTypeUnknown';
|
||||||
|
|
||||||
export interface ApiUserStatus {
|
export interface ApiUserStatus {
|
||||||
|
|||||||
11
src/components/common/FakeIcon.scss
Normal file
11
src/components/common/FakeIcon.scss
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
.FakeIcon {
|
||||||
|
border: 1px solid var(--color-error);
|
||||||
|
border-radius: 0.375rem;
|
||||||
|
color: var(--color-error);
|
||||||
|
font-size: 0.625rem;
|
||||||
|
padding: 0.125rem 0.25rem;
|
||||||
|
line-height: initial;
|
||||||
|
margin-inline: 0.25rem;
|
||||||
|
font-weight: 500;
|
||||||
|
text-transform: capitalize;
|
||||||
|
}
|
||||||
21
src/components/common/FakeIcon.tsx
Normal file
21
src/components/common/FakeIcon.tsx
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import React, { FC, memo } from '../../lib/teact/teact';
|
||||||
|
|
||||||
|
import { ApiFakeType } from '../../api/types';
|
||||||
|
|
||||||
|
import useLang from '../../hooks/useLang';
|
||||||
|
|
||||||
|
import './FakeIcon.scss';
|
||||||
|
|
||||||
|
type OwnProps = {
|
||||||
|
fakeType: ApiFakeType;
|
||||||
|
};
|
||||||
|
|
||||||
|
const FakeIcon: FC<OwnProps> = ({
|
||||||
|
fakeType,
|
||||||
|
}) => {
|
||||||
|
const lang = useLang();
|
||||||
|
|
||||||
|
return <span className="FakeIcon">{lang(fakeType === 'fake' ? 'FakeMessage' : 'ScamMessage')}</span>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default memo(FakeIcon);
|
||||||
@ -21,6 +21,7 @@ import Avatar from './Avatar';
|
|||||||
import VerifiedIcon from './VerifiedIcon';
|
import VerifiedIcon from './VerifiedIcon';
|
||||||
import TypingStatus from './TypingStatus';
|
import TypingStatus from './TypingStatus';
|
||||||
import DotAnimation from './DotAnimation';
|
import DotAnimation from './DotAnimation';
|
||||||
|
import FakeIcon from './FakeIcon';
|
||||||
|
|
||||||
type OwnProps = {
|
type OwnProps = {
|
||||||
chatId: string;
|
chatId: string;
|
||||||
@ -144,6 +145,7 @@ const GroupChatInfo: FC<OwnProps & StateProps> = ({
|
|||||||
<div className="title">
|
<div className="title">
|
||||||
<h3 dir="auto">{renderText(getChatTitle(lang, chat))}</h3>
|
<h3 dir="auto">{renderText(getChatTitle(lang, chat))}</h3>
|
||||||
{chat.isVerified && <VerifiedIcon />}
|
{chat.isVerified && <VerifiedIcon />}
|
||||||
|
{chat.fakeType && <FakeIcon fakeType={chat.fakeType} />}
|
||||||
</div>
|
</div>
|
||||||
{renderStatusOrTyping()}
|
{renderStatusOrTyping()}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import Avatar from './Avatar';
|
|||||||
import VerifiedIcon from './VerifiedIcon';
|
import VerifiedIcon from './VerifiedIcon';
|
||||||
import TypingStatus from './TypingStatus';
|
import TypingStatus from './TypingStatus';
|
||||||
import DotAnimation from './DotAnimation';
|
import DotAnimation from './DotAnimation';
|
||||||
|
import FakeIcon from './FakeIcon';
|
||||||
|
|
||||||
type OwnProps = {
|
type OwnProps = {
|
||||||
userId: string;
|
userId: string;
|
||||||
@ -140,6 +141,7 @@ const PrivateChatInfo: FC<OwnProps & StateProps> = ({
|
|||||||
<div className="title">
|
<div className="title">
|
||||||
<h3 dir="auto">{fullName && renderText(fullName)}</h3>
|
<h3 dir="auto">{fullName && renderText(fullName)}</h3>
|
||||||
{user?.isVerified && <VerifiedIcon />}
|
{user?.isVerified && <VerifiedIcon />}
|
||||||
|
{user.fakeType && <FakeIcon fakeType={user.fakeType} />}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{(status || (!isSavedMessages && !noStatusOrTyping)) && renderStatusOrTyping()}
|
{(status || (!isSavedMessages && !noStatusOrTyping)) && renderStatusOrTyping()}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import useLang from '../../hooks/useLang';
|
|||||||
import VerifiedIcon from './VerifiedIcon';
|
import VerifiedIcon from './VerifiedIcon';
|
||||||
import ProfilePhoto from './ProfilePhoto';
|
import ProfilePhoto from './ProfilePhoto';
|
||||||
import Transition from '../ui/Transition';
|
import Transition from '../ui/Transition';
|
||||||
|
import FakeIcon from './FakeIcon';
|
||||||
|
|
||||||
import './ProfileInfo.scss';
|
import './ProfileInfo.scss';
|
||||||
|
|
||||||
@ -185,6 +186,7 @@ const ProfileInfo: FC<OwnProps & StateProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isVerifiedIconShown = (user || chat)?.isVerified;
|
const isVerifiedIconShown = (user || chat)?.isVerified;
|
||||||
|
const fakeType = (user || chat)?.fakeType;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={buildClassName('ProfileInfo', forceShowSelf && 'self')} dir={lang.isRtl ? 'rtl' : undefined}>
|
<div className={buildClassName('ProfileInfo', forceShowSelf && 'self')} dir={lang.isRtl ? 'rtl' : undefined}>
|
||||||
@ -221,6 +223,7 @@ const ProfileInfo: FC<OwnProps & StateProps> = ({
|
|||||||
<div className="title">
|
<div className="title">
|
||||||
<h3 dir="auto">{fullName && renderText(fullName)}</h3>
|
<h3 dir="auto">{fullName && renderText(fullName)}</h3>
|
||||||
{isVerifiedIconShown && <VerifiedIcon />}
|
{isVerifiedIconShown && <VerifiedIcon />}
|
||||||
|
{fakeType && <FakeIcon fakeType={fakeType} />}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{!isSavedMessages && renderStatus()}
|
{!isSavedMessages && renderStatus()}
|
||||||
|
|||||||
@ -50,6 +50,7 @@ import ListItem from '../../ui/ListItem';
|
|||||||
import Badge from './Badge';
|
import Badge from './Badge';
|
||||||
import ChatFolderModal from '../ChatFolderModal.async';
|
import ChatFolderModal from '../ChatFolderModal.async';
|
||||||
import ChatCallStatus from './ChatCallStatus';
|
import ChatCallStatus from './ChatCallStatus';
|
||||||
|
import FakeIcon from '../../common/FakeIcon';
|
||||||
|
|
||||||
import './Chat.scss';
|
import './Chat.scss';
|
||||||
|
|
||||||
@ -299,6 +300,7 @@ const Chat: FC<OwnProps & StateProps> = ({
|
|||||||
<div className="title">
|
<div className="title">
|
||||||
<h3>{renderText(getChatTitle(lang, chat, user))}</h3>
|
<h3>{renderText(getChatTitle(lang, chat, user))}</h3>
|
||||||
{chat.isVerified && <VerifiedIcon />}
|
{chat.isVerified && <VerifiedIcon />}
|
||||||
|
{chat.fakeType && <FakeIcon fakeType={chat.fakeType} />}
|
||||||
{isMuted && <i className="icon-muted" />}
|
{isMuted && <i className="icon-muted" />}
|
||||||
{chat.lastMessage && (
|
{chat.lastMessage && (
|
||||||
<LastMessageMeta
|
<LastMessageMeta
|
||||||
|
|||||||
@ -30,6 +30,7 @@ import Avatar from '../../common/Avatar';
|
|||||||
import VerifiedIcon from '../../common/VerifiedIcon';
|
import VerifiedIcon from '../../common/VerifiedIcon';
|
||||||
import ListItem from '../../ui/ListItem';
|
import ListItem from '../../ui/ListItem';
|
||||||
import Link from '../../ui/Link';
|
import Link from '../../ui/Link';
|
||||||
|
import FakeIcon from '../../common/FakeIcon';
|
||||||
|
|
||||||
import './ChatMessage.scss';
|
import './ChatMessage.scss';
|
||||||
|
|
||||||
@ -90,6 +91,7 @@ const ChatMessage: FC<OwnProps & StateProps> = ({
|
|||||||
<div className="title">
|
<div className="title">
|
||||||
<h3 dir="auto">{renderText(getChatTitle(lang, chat, privateChatUser))}</h3>
|
<h3 dir="auto">{renderText(getChatTitle(lang, chat, privateChatUser))}</h3>
|
||||||
{chat.isVerified && <VerifiedIcon />}
|
{chat.isVerified && <VerifiedIcon />}
|
||||||
|
{chat.fakeType && <FakeIcon fakeType={chat.fakeType} />}
|
||||||
</div>
|
</div>
|
||||||
<div className="message-date">
|
<div className="message-date">
|
||||||
<Link className="date">
|
<Link className="date">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user