mirror of
https://github.com/fromchat-messenger/web.git
synced 2026-09-22 19:15:08 +03:00
Don't display deleted/suspended account profile data
This commit is contained in:
@@ -22,6 +22,16 @@ export function isDeletedPeer(user: {
|
||||
return isDeletedUser(user) || isDeletedAccountUsername(user.username);
|
||||
}
|
||||
|
||||
/** Peers should treat suspended accounts like deleted (no PII). */
|
||||
export function isRedactedPeer(user: {
|
||||
id?: number;
|
||||
deleted?: boolean;
|
||||
suspended?: boolean;
|
||||
username?: string | null;
|
||||
}): boolean {
|
||||
return isDeletedPeer(user) || isSuspendedUser(user);
|
||||
}
|
||||
|
||||
export const DELETED_ACCOUNT_LABEL = "Deleted account";
|
||||
|
||||
export function deletedUserLabel(): string {
|
||||
@@ -33,8 +43,9 @@ export function displayNameForUser(user: {
|
||||
display_name?: string | null;
|
||||
username?: string | null;
|
||||
deleted?: boolean;
|
||||
suspended?: boolean;
|
||||
}): string {
|
||||
if (isDeletedPeer(user)) {
|
||||
if (isRedactedPeer(user)) {
|
||||
return deletedUserLabel();
|
||||
}
|
||||
return user.display_name?.trim() || user.username?.trim() || "";
|
||||
|
||||
@@ -10,7 +10,7 @@ import { onlineStatusManager } from "@/core/onlineStatusManager";
|
||||
import { OnlineIndicator } from "@/pages/chat/ui/right/OnlineIndicator";
|
||||
import defaultAvatar from "@/images/default-avatar.png";
|
||||
import { MaterialBadge, MaterialCircularProgress, MaterialIcon, MaterialList, MaterialListItem } from "@/utils/material";
|
||||
import { displayNameForUser, isDeletedPeer } from "@/core/userDisplay";
|
||||
import { displayNameForUser, isRedactedPeer } from "@/core/userDisplay";
|
||||
import { DeletedUserAvatar } from "@/core/DeletedUserAvatar";
|
||||
import styles from "@/pages/chat/css/left-panel.module.scss";
|
||||
|
||||
@@ -229,7 +229,7 @@ export function UnifiedChatsList() {
|
||||
);
|
||||
}
|
||||
|
||||
const isDeletedDm = isDeletedPeer(chat);
|
||||
const isDeletedDm = isRedactedPeer(chat);
|
||||
const displayName = displayNameForUser({ ...chat, id: chat.id });
|
||||
|
||||
return (
|
||||
|
||||
@@ -14,7 +14,7 @@ import { useImmer } from "use-immer";
|
||||
import { createPortal } from "react-dom";
|
||||
import { parseProfileLink } from "@/core/profileLinks";
|
||||
import { MaterialCircularProgress, MaterialIconButton, MaterialList, MaterialListItem } from "@/utils/material";
|
||||
import { displayNameForUser, isDeletedPeer } from "@/core/userDisplay";
|
||||
import { displayNameForUser, isRedactedPeer } from "@/core/userDisplay";
|
||||
import { DeletedUserAvatar } from "@/core/DeletedUserAvatar";
|
||||
import styles from "@/pages/chat/css/Message.module.scss";
|
||||
import replyPreviewStyles from "@/pages/chat/css/reply-preview.module.scss";
|
||||
@@ -519,7 +519,7 @@ export function Message({ message, isAuthor, onContextMenu, onReactionClick, isD
|
||||
return messageText.length > 0 && emojiRegex.test(messageText) && messageText.length <= 4; // Most emojis are 1-4 characters
|
||||
}, [messageText]);
|
||||
|
||||
const isDeletedSender = isDeletedPeer({ id: message.user_id, username: message.username });
|
||||
const isDeletedSender = isRedactedPeer({ id: message.user_id, username: message.username });
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user