Browse Source

Fake & scam badge

master
Eduard Kuzmenko 3 years ago
parent
commit
fea9019d8e
  1. 8
      src/components/chat/topbar.ts
  2. 8
      src/components/generateFakeIcon.ts
  3. 18
      src/components/generateTitleIcons.ts
  4. 7
      src/components/peerProfile.ts
  5. 2
      src/lang.ts
  6. 9
      src/lib/appManagers/appDialogsManager.ts
  7. 5
      src/scss/partials/_chatlist.scss
  8. 4
      src/scss/partials/_profile.scss
  9. 11
      src/scss/style.scss

8
src/components/chat/topbar.ts

@ -41,15 +41,14 @@ import replaceContent from "../../helpers/dom/replaceContent";
import { ChatFull, Chat as MTChat, GroupCall } from "../../layer"; import { ChatFull, Chat as MTChat, GroupCall } from "../../layer";
import PopupPickUser from "../popups/pickUser"; import PopupPickUser from "../popups/pickUser";
import PopupPeer from "../popups/peer"; import PopupPeer from "../popups/peer";
import generateVerifiedIcon from "../generateVerifiedIcon";
import { fastRaf } from "../../helpers/schedulers"; import { fastRaf } from "../../helpers/schedulers";
import AppEditContactTab from "../sidebarRight/tabs/editContact"; import AppEditContactTab from "../sidebarRight/tabs/editContact";
import appMediaPlaybackController from "../appMediaPlaybackController"; import appMediaPlaybackController from "../appMediaPlaybackController";
import { NULL_PEER_ID } from "../../lib/mtproto/mtproto_config";
import IS_GROUP_CALL_SUPPORTED from "../../environment/groupCallSupport"; import IS_GROUP_CALL_SUPPORTED from "../../environment/groupCallSupport";
import IS_CALL_SUPPORTED from "../../environment/callSupport"; import IS_CALL_SUPPORTED from "../../environment/callSupport";
import { CallType } from "../../lib/calls/types"; import { CallType } from "../../lib/calls/types";
import PopupMute from "../popups/mute"; import PopupMute from "../popups/mute";
import generateTitleIcons from "../generateTitleIcons";
type ButtonToVerify = {element?: HTMLElement, verify: () => boolean}; type ButtonToVerify = {element?: HTMLElement, verify: () => boolean};
@ -809,10 +808,7 @@ export default class ChatTopbar {
replaceContent(this.title, titleEl); replaceContent(this.title, titleEl);
if(this.chat.type === 'chat') { if(this.chat.type === 'chat') {
const peer = this.appPeersManager.getPeer(this.peerId); this.title.append(...generateTitleIcons(this.peerId));
if(peer?.pFlags?.verified) {
this.title.append(generateVerifiedIcon());
}
} }
} }

8
src/components/generateFakeIcon.ts

@ -0,0 +1,8 @@
import { _i18n } from "../lib/langPack";
export default function generateFakeIcon(isScam?: boolean) {
const span = document.createElement('span');
span.classList.add('badge-fake');
_i18n(span, isScam ? 'ScamMessage' : 'FakeMessage');
return span;
}

18
src/components/generateTitleIcons.ts

@ -0,0 +1,18 @@
import { Chat, User } from "../layer";
import appPeersManager from "../lib/appManagers/appPeersManager";
import generateFakeIcon from "./generateFakeIcon";
import generateVerifiedIcon from "./generateVerifiedIcon";
export default function generateTitleIcons(peerId: PeerId) {
const elements: Element[] = [];
const peer = appPeersManager.getPeer(peerId);
if(peer?.pFlags?.verified) {
elements.push(generateVerifiedIcon());
}
if((peer as Chat.channel).pFlags.fake || (peer as User.user).pFlags.scam) {
elements.push(generateFakeIcon((peer as User.user).pFlags.scam));
}
return elements;
}

7
src/components/peerProfile.ts

@ -23,7 +23,7 @@ import RichTextProcessor from "../lib/richtextprocessor";
import rootScope from "../lib/rootScope"; import rootScope from "../lib/rootScope";
import AvatarElement from "./avatar"; import AvatarElement from "./avatar";
import CheckboxField from "./checkboxField"; import CheckboxField from "./checkboxField";
import generateVerifiedIcon from "./generateVerifiedIcon"; import generateTitleIcons from "./generateTitleIcons";
import PeerProfileAvatars from "./peerProfileAvatars"; import PeerProfileAvatars from "./peerProfileAvatars";
import PeerTitle from "./peerTitle"; import PeerTitle from "./peerTitle";
import Row from "./row"; import Row from "./row";
@ -357,10 +357,7 @@ export default class PeerProfile {
dialog: this.isDialog, dialog: this.isDialog,
}).element); }).element);
const peer = appPeersManager.getPeer(peerId); this.name.append(...generateTitleIcons(peerId));
if(peer?.pFlags?.verified) {
this.name.append(generateVerifiedIcon());
}
this.setPeerStatus(true); this.setPeerStatus(true);
} }

2
src/lang.ts

@ -690,6 +690,8 @@ const lang = {
"ReportChatPersonalDetails": "Personal Details", "ReportChatPersonalDetails": "Personal Details",
"VoipPeerIncompatible": "**%1$s**'s app is using an incompatible protocol. They need to update their app before you can call them.", "VoipPeerIncompatible": "**%1$s**'s app is using an incompatible protocol. They need to update their app before you can call them.",
"TelegramFeaturesUrl": "https://t.me/TelegramTips", "TelegramFeaturesUrl": "https://t.me/TelegramTips",
"ScamMessage": "SCAM",
"FakeMessage": "FAKE",
// * macos // * macos
"AccountSettings.Filters": "Chat Folders", "AccountSettings.Filters": "Chat Folders",

9
src/lib/appManagers/appDialogsManager.ts

@ -23,7 +23,7 @@ import appPeersManager from './appPeersManager';
import appImManager from "./appImManager"; import appImManager from "./appImManager";
import appMessagesManager, { Dialog, MyMessage } from "./appMessagesManager"; import appMessagesManager, { Dialog, MyMessage } from "./appMessagesManager";
import appStateManager, { State } from "./appStateManager"; import appStateManager, { State } from "./appStateManager";
import appUsersManager from "./appUsersManager"; import appUsersManager, { User } from "./appUsersManager";
import Button from "../../components/button"; import Button from "../../components/button";
import SetTransition from "../../components/singleTransition"; import SetTransition from "../../components/singleTransition";
import appDraftsManager, { MyDraftMessage } from "./appDraftsManager"; import appDraftsManager, { MyDraftMessage } from "./appDraftsManager";
@ -53,7 +53,6 @@ import { MyDocument } from "./appDocsManager";
import { setSendingStatus } from "../../components/sendingStatus"; import { setSendingStatus } from "../../components/sendingStatus";
import SortedList, { SortedElementBase } from "../../helpers/sortedList"; import SortedList, { SortedElementBase } from "../../helpers/sortedList";
import debounce from "../../helpers/schedulers/debounce"; import debounce from "../../helpers/schedulers/debounce";
import generateVerifiedIcon from "../../components/generateVerifiedIcon";
import { NULL_PEER_ID } from "../mtproto/mtproto_config"; import { NULL_PEER_ID } from "../mtproto/mtproto_config";
import groupCallActiveIcon from "../../components/groupCallActiveIcon"; import groupCallActiveIcon from "../../components/groupCallActiveIcon";
import { Chat, NotifyPeer } from "../../layer"; import { Chat, NotifyPeer } from "../../layer";
@ -61,6 +60,7 @@ import IS_GROUP_CALL_SUPPORTED from "../../environment/groupCallSupport";
import mediaSizes from "../../helpers/mediaSizes"; import mediaSizes from "../../helpers/mediaSizes";
import appNavigationController, { NavigationItem } from "../../components/appNavigationController"; import appNavigationController, { NavigationItem } from "../../components/appNavigationController";
import assumeType from "../../helpers/assumeType"; import assumeType from "../../helpers/assumeType";
import generateTitleIcons from "../../components/generateTitleIcons";
export type DialogDom = { export type DialogDom = {
avatarEl: AvatarElement, avatarEl: AvatarElement,
@ -1851,10 +1851,7 @@ export class AppDialogsManager {
// for muted icon // for muted icon
titleSpanContainer.classList.add('tgico'); // * эта строка будет актуальна только для !container, но ладно titleSpanContainer.classList.add('tgico'); // * эта строка будет актуальна только для !container, но ладно
const peer = appPeersManager.getPeer(peerId); titleSpanContainer.append(...generateTitleIcons(peerId));
if(peer?.pFlags?.verified) {
titleSpanContainer.append(generateVerifiedIcon());
}
//} //}
const span = document.createElement('span'); const span = document.createElement('span');

5
src/scss/partials/_chatlist.scss

@ -269,6 +269,11 @@ ul.chatlist {
color: #fff; color: #fff;
} }
.badge-fake {
color: #fff;
border-color: #fff;
}
b { b {
color: #fff !important; color: #fff !important;
} }

4
src/scss/partials/_profile.scss

@ -309,6 +309,10 @@
.sidebar-left-section-content > & { .sidebar-left-section-content > & {
justify-content: center; justify-content: center;
} }
.badge-fake {
align-self: center;
}
} }
&-subtitle { &-subtitle {

11
src/scss/style.scss

@ -1608,6 +1608,17 @@ hr {
margin-left: .125rem; margin-left: .125rem;
} }
.badge-fake {
color: var(--danger-color);
border: 1px solid var(--danger-color);
padding: .125rem .25rem;
border-radius: .185rem;
font-size: .625rem;
font-weight: 500;
line-height: 1 !important;
margin: 0 .25rem;
}
.movable-element { .movable-element {
--size: .5rem; --size: .5rem;
position: relative; position: relative;

Loading…
Cancel
Save