From 3603168978622e70f2ef29e5e99ecef04856839f Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Fri, 6 Dec 2024 19:44:07 +0400 Subject: [PATCH] Privacy Gifts: Support settings (#5262) --- src/api/gramjs/apiBuilders/common.ts | 8 +- src/api/gramjs/apiBuilders/misc.ts | 2 + src/api/gramjs/gramjsBuilders/index.ts | 11 ++ src/assets/localization/fallback.strings | 5 + src/components/left/LeftColumn.tsx | 5 + src/components/left/settings/Settings.tsx | 10 ++ .../left/settings/SettingsHeader.tsx | 112 +++++++++--------- .../left/settings/SettingsPrivacy.tsx | 102 ++++++++++------ .../settings/SettingsPrivacyVisibility.tsx | 112 +++++++++++------- ...SettingsPrivacyVisibilityExceptionList.tsx | 63 ++++++++-- .../left/settings/helpers/privacy.ts | 4 + src/global/actions/api/settings.ts | 7 +- src/global/actions/api/stories.ts | 8 +- src/global/helpers/misc.ts | 5 +- src/global/types.ts | 2 + src/types/index.ts | 9 +- src/types/language.d.ts | 5 + 17 files changed, 316 insertions(+), 154 deletions(-) diff --git a/src/api/gramjs/apiBuilders/common.ts b/src/api/gramjs/apiBuilders/common.ts index f5a577540..581e34c75 100644 --- a/src/api/gramjs/apiBuilders/common.ts +++ b/src/api/gramjs/apiBuilders/common.ts @@ -1,7 +1,7 @@ import { Api as GramJs } from '../../../lib/gramjs'; import { strippedPhotoToJpg } from '../../../lib/gramjs/Utils'; -import type { ApiPrivacySettings, PrivacyVisibility } from '../../../types'; +import type { ApiPrivacySettings, BotsPrivacyType, PrivacyVisibility } from '../../../types'; import type { ApiFormattedText, ApiMessageEntity, @@ -163,6 +163,7 @@ export function buildPrivacyRules(rules: GramJs.TypePrivacyRule[]): ApiPrivacySe let blockUserIds: string[] | undefined; let blockChatIds: string[] | undefined; let shouldAllowPremium: true | undefined; + let botsPrivacy: BotsPrivacyType = 'none'; const localChats = localDb.chats; @@ -198,6 +199,10 @@ export function buildPrivacyRules(rules: GramJs.TypePrivacyRule[]): ApiPrivacySe }); } else if (rule instanceof GramJs.PrivacyValueAllowPremium) { shouldAllowPremium = true; + } else if (rule instanceof GramJs.PrivacyValueAllowBots) { + botsPrivacy = 'allow'; + } else if (rule instanceof GramJs.PrivacyValueDisallowBots) { + botsPrivacy = 'disallow'; } }); @@ -215,6 +220,7 @@ export function buildPrivacyRules(rules: GramJs.TypePrivacyRule[]): ApiPrivacySe blockUserIds: blockUserIds || [], blockChatIds: blockChatIds || [], shouldAllowPremium, + botsPrivacy, }; } diff --git a/src/api/gramjs/apiBuilders/misc.ts b/src/api/gramjs/apiBuilders/misc.ts index 11f7b571d..aa5faf980 100644 --- a/src/api/gramjs/apiBuilders/misc.ts +++ b/src/api/gramjs/apiBuilders/misc.ts @@ -91,6 +91,8 @@ export function buildPrivacyKey(key: GramJs.TypePrivacyKey): ApiPrivacyKey | und return 'bio'; case 'PrivacyKeyBirthday': return 'birthday'; + case 'PrivacyKeyStarGiftsAutoSave': + return 'gifts'; } return undefined; diff --git a/src/api/gramjs/gramjsBuilders/index.ts b/src/api/gramjs/gramjsBuilders/index.ts index 32cd95d51..06fe3776d 100644 --- a/src/api/gramjs/gramjsBuilders/index.ts +++ b/src/api/gramjs/gramjsBuilders/index.ts @@ -466,6 +466,9 @@ export function buildInputPrivacyKey(privacyKey: ApiPrivacyKey) { case 'birthday': return new GramJs.InputPrivacyKeyBirthday(); + + case 'gifts': + return new GramJs.InputPrivacyKeyStarGiftsAutoSave(); } return undefined; @@ -800,6 +803,14 @@ export function buildInputPrivacyRules( privacyRules.push(new GramJs.InputPrivacyValueAllowPremium()); } + if (rules.botsPrivacy === 'allow') { + privacyRules.push(new GramJs.InputPrivacyValueAllowBots()); + } + + if (rules.botsPrivacy === 'disallow') { + privacyRules.push(new GramJs.InputPrivacyValueDisallowBots()); + } + if (!rules.isUnspecified) { switch (rules.visibility) { case 'everybody': diff --git a/src/assets/localization/fallback.strings b/src/assets/localization/fallback.strings index da17a0c57..8dd719ea2 100644 --- a/src/assets/localization/fallback.strings +++ b/src/assets/localization/fallback.strings @@ -1393,6 +1393,11 @@ "BotSuggestedStatus" = "Do you want to set this emoji status suggested by **{bot}**?"; "BotSuggestedStatusTitle" = "Set Emoji Status"; "BotSuggestedStatusUpdated" = "Your emoji status is updated."; +"PrivacyGifts" = "Gifts"; +"PrivacyGiftsTitle" = "Who can display gifts on my profile?" +"PrivacyGiftsInfo" = "Choose whether gifts from specific senders need your approval before they're visible to others on your profile." +"PrivacyValueBots" = "Mini Apps" +"CustomShareGiftsInfo" = "You can add users or entire groups as exceptions that will override the settings above." "StarsSubscribeBotText_one" = "Do you want to subscribe to **{name}** in **{bot}** for **{amount}** star per month?" "StarsSubscribeBotText_other" = "Do you want to subscribe to **{name}** in **{bot}** for **{amount}** stars per month?" "StarsSubscribeBotButtonMonth" = "Subscribe for {amount} / month"; diff --git a/src/components/left/LeftColumn.tsx b/src/components/left/LeftColumn.tsx index 6e54434dc..fc10126ce 100644 --- a/src/components/left/LeftColumn.tsx +++ b/src/components/left/LeftColumn.tsx @@ -192,6 +192,7 @@ function LeftColumn({ case SettingsScreens.PrivacyProfilePhoto: case SettingsScreens.PrivacyBio: case SettingsScreens.PrivacyBirthday: + case SettingsScreens.PrivacyGifts: case SettingsScreens.PrivacyPhoneCall: case SettingsScreens.PrivacyPhoneP2P: case SettingsScreens.PrivacyForwarding: @@ -250,6 +251,10 @@ function LeftColumn({ case SettingsScreens.PrivacyBirthdayDeniedContacts: setSettingsScreen(SettingsScreens.PrivacyBirthday); return; + case SettingsScreens.PrivacyGiftsAllowedContacts: + case SettingsScreens.PrivacyGiftsDeniedContacts: + setSettingsScreen(SettingsScreens.PrivacyGifts); + return; case SettingsScreens.PrivacyPhoneCallAllowedContacts: case SettingsScreens.PrivacyPhoneCallDeniedContacts: setSettingsScreen(SettingsScreens.PrivacyPhoneCall); diff --git a/src/components/left/settings/Settings.tsx b/src/components/left/settings/Settings.tsx index f2ad957dd..ea4d8cace 100644 --- a/src/components/left/settings/Settings.tsx +++ b/src/components/left/settings/Settings.tsx @@ -110,6 +110,11 @@ const PRIVACY_BIRTHDAY_SCREENS = [ SettingsScreens.PrivacyBirthdayDeniedContacts, ]; +const PRIVACY_GIFTS_SCREENS = [ + SettingsScreens.PrivacyGiftsAllowedContacts, + SettingsScreens.PrivacyGiftsDeniedContacts, +]; + const PRIVACY_PHONE_CALL_SCREENS = [ SettingsScreens.PrivacyPhoneCallAllowedContacts, SettingsScreens.PrivacyPhoneCallDeniedContacts, @@ -204,6 +209,7 @@ const Settings: FC = ({ [SettingsScreens.PrivacyProfilePhoto]: PRIVACY_PROFILE_PHOTO_SCREENS.includes(activeScreen), [SettingsScreens.PrivacyBio]: PRIVACY_BIO_SCREENS.includes(activeScreen), [SettingsScreens.PrivacyBirthday]: PRIVACY_BIRTHDAY_SCREENS.includes(activeScreen), + [SettingsScreens.PrivacyGifts]: PRIVACY_GIFTS_SCREENS.includes(activeScreen), [SettingsScreens.PrivacyPhoneCall]: PRIVACY_PHONE_CALL_SCREENS.includes(activeScreen), [SettingsScreens.PrivacyPhoneP2P]: PRIVACY_PHONE_P2P_SCREENS.includes(activeScreen), [SettingsScreens.PrivacyForwarding]: PRIVACY_FORWARDING_SCREENS.includes(activeScreen), @@ -330,6 +336,7 @@ const Settings: FC = ({ case SettingsScreens.PrivacyProfilePhoto: case SettingsScreens.PrivacyBio: case SettingsScreens.PrivacyBirthday: + case SettingsScreens.PrivacyGifts: case SettingsScreens.PrivacyPhoneCall: case SettingsScreens.PrivacyForwarding: case SettingsScreens.PrivacyVoiceMessages: @@ -348,6 +355,7 @@ const Settings: FC = ({ case SettingsScreens.PrivacyProfilePhotoAllowedContacts: case SettingsScreens.PrivacyBioAllowedContacts: case SettingsScreens.PrivacyBirthdayAllowedContacts: + case SettingsScreens.PrivacyGiftsAllowedContacts: case SettingsScreens.PrivacyPhoneCallAllowedContacts: case SettingsScreens.PrivacyPhoneP2PAllowedContacts: case SettingsScreens.PrivacyForwardingAllowedContacts: @@ -357,6 +365,7 @@ const Settings: FC = ({ = ({ case SettingsScreens.PrivacyProfilePhotoDeniedContacts: case SettingsScreens.PrivacyBioDeniedContacts: case SettingsScreens.PrivacyBirthdayDeniedContacts: + case SettingsScreens.PrivacyGiftsDeniedContacts: case SettingsScreens.PrivacyPhoneCallDeniedContacts: case SettingsScreens.PrivacyPhoneP2PDeniedContacts: case SettingsScreens.PrivacyForwardingDeniedContacts: diff --git a/src/components/left/settings/SettingsHeader.tsx b/src/components/left/settings/SettingsHeader.tsx index 9d331c864..688dfaab4 100644 --- a/src/components/left/settings/SettingsHeader.tsx +++ b/src/components/left/settings/SettingsHeader.tsx @@ -7,6 +7,7 @@ import { getActions } from '../../../global'; import { SettingsScreens } from '../../../types'; import useAppLayout from '../../../hooks/useAppLayout'; +import useLang from '../../../hooks/useLang'; import useMultiClick from '../../../hooks/useMultiClick'; import useOldLang from '../../../hooks/useOldLang'; @@ -75,146 +76,151 @@ const SettingsHeader: FC = ({ ); }, [isMobile]); - const lang = useOldLang(); + const oldLang = useOldLang(); + const lang = useLang(); function renderHeaderContent() { switch (currentScreen) { case SettingsScreens.EditProfile: - return

{lang('lng_settings_information')}

; + return

{oldLang('lng_settings_information')}

; case SettingsScreens.General: - return

{lang('General')}

; + return

{oldLang('General')}

; case SettingsScreens.QuickReaction: - return

{lang('DoubleTapSetting')}

; + return

{oldLang('DoubleTapSetting')}

; case SettingsScreens.CustomEmoji: - return

{lang('Emoji')}

; + return

{oldLang('Emoji')}

; case SettingsScreens.Notifications: - return

{lang('Notifications')}

; + return

{oldLang('Notifications')}

; case SettingsScreens.DataStorage: - return

{lang('DataSettings')}

; + return

{oldLang('DataSettings')}

; case SettingsScreens.Privacy: - return

{lang('PrivacySettings')}

; + return

{oldLang('PrivacySettings')}

; case SettingsScreens.Language: - return

{lang('Language')}

; + return

{oldLang('Language')}

; case SettingsScreens.DoNotTranslate: - return

{lang('DoNotTranslate')}

; + return

{oldLang('DoNotTranslate')}

; case SettingsScreens.Stickers: - return

{lang('StickersName')}

; + return

{oldLang('StickersName')}

; case SettingsScreens.Experimental: - return

{lang('lng_settings_experimental')}

; + return

{oldLang('lng_settings_experimental')}

; case SettingsScreens.GeneralChatBackground: - return

{lang('ChatBackground')}

; + return

{oldLang('ChatBackground')}

; case SettingsScreens.GeneralChatBackgroundColor: - return

{lang('SetColor')}

; + return

{oldLang('SetColor')}

; case SettingsScreens.PrivacyPhoneNumber: - return

{lang('PrivacyPhone')}

; + return

{oldLang('PrivacyPhone')}

; case SettingsScreens.PrivacyLastSeen: - return

{lang('PrivacyLastSeen')}

; + return

{oldLang('PrivacyLastSeen')}

; case SettingsScreens.PrivacyProfilePhoto: - return

{lang('Privacy.ProfilePhoto')}

; + return

{oldLang('Privacy.ProfilePhoto')}

; case SettingsScreens.PrivacyBio: - return

{lang('PrivacyBio')}

; + return

{oldLang('PrivacyBio')}

; case SettingsScreens.PrivacyBirthday: - return

{lang('PrivacyBirthday')}

; + return

{oldLang('PrivacyBirthday')}

; + case SettingsScreens.PrivacyGifts: + return

{lang('PrivacyGifts')}

; case SettingsScreens.PrivacyForwarding: - return

{lang('PrivacyForwards')}

; + return

{oldLang('PrivacyForwards')}

; case SettingsScreens.PrivacyVoiceMessages: - return

{lang('PrivacyVoiceMessages')}

; + return

{oldLang('PrivacyVoiceMessages')}

; case SettingsScreens.PrivacyMessages: - return

{lang('PrivacyMessages')}

; + return

{oldLang('PrivacyMessages')}

; case SettingsScreens.PrivacyGroupChats: - return

{lang('AutodownloadGroupChats')}

; + return

{oldLang('AutodownloadGroupChats')}

; case SettingsScreens.PrivacyPhoneCall: - return

{lang('Calls')}

; + return

{oldLang('Calls')}

; case SettingsScreens.PrivacyPhoneNumberAllowedContacts: case SettingsScreens.PrivacyLastSeenAllowedContacts: case SettingsScreens.PrivacyProfilePhotoAllowedContacts: case SettingsScreens.PrivacyBioAllowedContacts: case SettingsScreens.PrivacyBirthdayAllowedContacts: + case SettingsScreens.PrivacyGiftsAllowedContacts: case SettingsScreens.PrivacyForwardingAllowedContacts: case SettingsScreens.PrivacyVoiceMessagesAllowedContacts: case SettingsScreens.PrivacyGroupChatsAllowedContacts: case SettingsScreens.PrivacyPhoneCallAllowedContacts: case SettingsScreens.PrivacyPhoneP2PAllowedContacts: - return

{lang('AlwaysShareWith')}

; + return

{oldLang('AlwaysShareWith')}

; case SettingsScreens.PrivacyPhoneNumberDeniedContacts: case SettingsScreens.PrivacyLastSeenDeniedContacts: case SettingsScreens.PrivacyProfilePhotoDeniedContacts: case SettingsScreens.PrivacyBioDeniedContacts: case SettingsScreens.PrivacyBirthdayDeniedContacts: + case SettingsScreens.PrivacyGiftsDeniedContacts: case SettingsScreens.PrivacyForwardingDeniedContacts: case SettingsScreens.PrivacyVoiceMessagesDeniedContacts: case SettingsScreens.PrivacyGroupChatsDeniedContacts: case SettingsScreens.PrivacyPhoneCallDeniedContacts: case SettingsScreens.PrivacyPhoneP2PDeniedContacts: - return

{lang('NeverShareWith')}

; + return

{oldLang('NeverShareWith')}

; case SettingsScreens.Performance: - return

{lang('Animations and Performance')}

; + return

{oldLang('Animations and Performance')}

; case SettingsScreens.ActiveSessions: - return

{lang('SessionsTitle')}

; + return

{oldLang('SessionsTitle')}

; case SettingsScreens.ActiveWebsites: - return

{lang('OtherWebSessions')}

; + return

{oldLang('OtherWebSessions')}

; case SettingsScreens.PrivacyBlockedUsers: - return

{lang('BlockedUsers')}

; + return

{oldLang('BlockedUsers')}

; case SettingsScreens.TwoFaDisabled: case SettingsScreens.TwoFaEnabled: - return

{lang('TwoStepVerification')}

; + return

{oldLang('TwoStepVerification')}

; case SettingsScreens.TwoFaNewPassword: case SettingsScreens.TwoFaChangePasswordNew: case SettingsScreens.TwoFaChangePasswordConfirm: - return

{lang('PleaseEnterCurrentPassword')}

; + return

{oldLang('PleaseEnterCurrentPassword')}

; case SettingsScreens.TwoFaNewPasswordConfirm: - return

{lang('PleaseReEnterPassword')}

; + return

{oldLang('PleaseReEnterPassword')}

; case SettingsScreens.TwoFaNewPasswordHint: case SettingsScreens.TwoFaChangePasswordHint: - return

{lang('PasswordHint')}

; + return

{oldLang('PasswordHint')}

; case SettingsScreens.TwoFaNewPasswordEmail: case SettingsScreens.TwoFaRecoveryEmail: - return

{lang('RecoveryEmailTitle')}

; + return

{oldLang('RecoveryEmailTitle')}

; case SettingsScreens.TwoFaNewPasswordEmailCode: case SettingsScreens.TwoFaRecoveryEmailCode: return

Recovery Email Code

; case SettingsScreens.TwoFaCongratulations: - return

{lang('TwoStepVerificationPasswordSet')}

; + return

{oldLang('TwoStepVerificationPasswordSet')}

; case SettingsScreens.TwoFaChangePasswordCurrent: case SettingsScreens.TwoFaTurnOff: case SettingsScreens.TwoFaRecoveryEmailCurrentPassword: - return

{lang('PleaseEnterCurrentPassword')}

; + return

{oldLang('PleaseEnterCurrentPassword')}

; case SettingsScreens.PasscodeDisabled: case SettingsScreens.PasscodeEnabled: case SettingsScreens.PasscodeNewPasscode: case SettingsScreens.PasscodeNewPasscodeConfirm: case SettingsScreens.PasscodeCongratulations: - return

{lang('Passcode')}

; + return

{oldLang('Passcode')}

; case SettingsScreens.PasscodeTurnOff: - return

{lang('PasscodeController.Disable.Title')}

; + return

{oldLang('PasscodeController.Disable.Title')}

; case SettingsScreens.PasscodeChangePasscodeCurrent: case SettingsScreens.PasscodeChangePasscodeNew: - return

{lang('PasscodeController.Change.Title')}

; + return

{oldLang('PasscodeController.Change.Title')}

; case SettingsScreens.PasscodeChangePasscodeConfirm: - return

{lang('PasscodeController.ReEnterPasscode.Placeholder')}

; + return

{oldLang('PasscodeController.ReEnterPasscode.Placeholder')}

; case SettingsScreens.Folders: - return

{lang('Filters')}

; + return

{oldLang('Filters')}

; case SettingsScreens.FoldersCreateFolder: - return

{lang('FilterNew')}

; + return

{oldLang('FilterNew')}

; case SettingsScreens.FoldersShare: - return

{lang('FolderLinkScreen.Title')}

; + return

{oldLang('FolderLinkScreen.Title')}

; case SettingsScreens.FoldersEditFolder: case SettingsScreens.FoldersEditFolderFromChatList: case SettingsScreens.FoldersEditFolderInvites: return (
-

{lang('FilterEdit')}

+

{oldLang('FilterEdit')}

{Boolean(editedFolderId) && ( = ({ positionX="right" > - {lang('Delete')} + {oldLang('Delete')} )} @@ -234,7 +240,7 @@ const SettingsHeader: FC = ({ case SettingsScreens.FoldersExcludedChatsFromChatList: return (

- {lang( + {oldLang( currentScreen === SettingsScreens.FoldersIncludedChats || currentScreen === SettingsScreens.FoldersIncludedChatsFromChatList ? 'FilterInclude' : 'FilterExclude', @@ -246,7 +252,7 @@ const SettingsHeader: FC = ({
{/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */}

- {lang('SETTINGS')} + {oldLang('SETTINGS')}

@@ -265,7 +271,7 @@ const SettingsHeader: FC = ({ trigger={SettingsMenuButton} positionX="right" > - {lang('LogOutTitle')} + {oldLang('LogOutTitle')}
); @@ -279,7 +285,7 @@ const SettingsHeader: FC = ({ size="smaller" color="translucent" onClick={onReset} - ariaLabel={lang('AccDescrGoBack')} + ariaLabel={oldLang('AccDescrGoBack')} > @@ -287,8 +293,8 @@ const SettingsHeader: FC = ({ diff --git a/src/components/left/settings/SettingsPrivacy.tsx b/src/components/left/settings/SettingsPrivacy.tsx index 02b71b69b..ddd87f82b 100644 --- a/src/components/left/settings/SettingsPrivacy.tsx +++ b/src/components/left/settings/SettingsPrivacy.tsx @@ -9,6 +9,7 @@ import { SettingsScreens } from '../../../types'; import { selectCanSetPasscode, selectIsCurrentUserPremium } from '../../../global/selectors'; import useHistoryBack from '../../../hooks/useHistoryBack'; +import useLang from '../../../hooks/useLang'; import useOldLang from '../../../hooks/useOldLang'; import StarIcon from '../../common/icons/StarIcon'; @@ -79,7 +80,8 @@ const SettingsPrivacy: FC = ({ } }, [isActive, loadGlobalPrivacySettings]); - const lang = useOldLang(); + const oldLang = useOldLang(); + const lang = useLang(); useHistoryBack({ isActive, @@ -103,30 +105,39 @@ const SettingsPrivacy: FC = ({ }, [updateContentSettings]); function getVisibilityValue(setting?: ApiPrivacySettings) { - if (!setting) return lang('Loading'); + if (!setting) return oldLang('Loading'); + + const { visibility, shouldAllowPremium, botsPrivacy } = setting; + + const isAllowBots = botsPrivacy === 'allow'; + const isVisibilityEverybody = visibility === 'everybody'; + const shouldShowBotsString = isAllowBots && !isVisibilityEverybody; - const { visibility, shouldAllowPremium } = setting; const blockCount = setting.blockChatIds.length + setting.blockUserIds.length; const allowCount = setting.allowChatIds.length + setting.allowUserIds.length; const total = []; if (blockCount) total.push(`-${blockCount}`); - if (allowCount) total.push(`+${allowCount}`); + if (allowCount && !isVisibilityEverybody) total.push(`+${allowCount}`); - const exceptionString = total.length ? `(${total.join(',')})` : ''; + const botPrivacyString = shouldShowBotsString ? lang('PrivacyValueBots') : ''; + const totalString = lang.conjunction(total); + + const exceptionString = [botPrivacyString, totalString].filter(Boolean).join(' '); + if (shouldShowBotsString && !isVisibilityEverybody) return exceptionString; if (shouldAllowPremium) { - return lang(exceptionString ? 'ContactsAndPremium' : 'PrivacyPremium'); + return oldLang(exceptionString ? 'ContactsAndPremium' : 'PrivacyPremium'); } switch (visibility) { case 'everybody': - return `${lang('P2PEverybody')} ${exceptionString}`; + return `${oldLang('P2PEverybody')} ${exceptionString}`; case 'contacts': - return `${lang('P2PContacts')} ${exceptionString}`; + return `${oldLang('P2PContacts')} ${exceptionString}`; case 'nobody': - return `${lang('P2PNobody')} ${exceptionString}`; + return `${oldLang('P2PNobody')} ${exceptionString}`; } return undefined; @@ -141,7 +152,7 @@ const SettingsPrivacy: FC = ({ // eslint-disable-next-line react/jsx-no-bind onClick={() => onScreenSelect(SettingsScreens.PrivacyBlockedUsers)} > - {lang('BlockedUsers')} + {oldLang('BlockedUsers')} {blockedCount || ''} {canSetPasscode && ( @@ -154,9 +165,9 @@ const SettingsPrivacy: FC = ({ )} >
- {lang('Passcode')} + {oldLang('Passcode')} - {lang(hasPasscode ? 'PasswordOn' : 'PasswordOff')} + {oldLang(hasPasscode ? 'PasswordOn' : 'PasswordOff')}
@@ -170,9 +181,9 @@ const SettingsPrivacy: FC = ({ )} >
- {lang('TwoStepVerification')} + {oldLang('TwoStepVerification')} - {lang(hasPassword ? 'PasswordOn' : 'PasswordOff')} + {oldLang(hasPassword ? 'PasswordOn' : 'PasswordOff')}
@@ -183,14 +194,14 @@ const SettingsPrivacy: FC = ({ // eslint-disable-next-line react/jsx-no-bind onClick={() => onScreenSelect(SettingsScreens.ActiveWebsites)} > - {lang('PrivacySettings.WebSessions')} + {oldLang('PrivacySettings.WebSessions')} {webAuthCount} )}

-

{lang('PrivacyTitle')}

+

{oldLang('PrivacyTitle')}

= ({ onClick={() => onScreenSelect(SettingsScreens.PrivacyPhoneNumber)} >
- {lang('PrivacyPhoneTitle')} + {oldLang('PrivacyPhoneTitle')} {getVisibilityValue(privacy.phoneNumber)} @@ -212,7 +223,7 @@ const SettingsPrivacy: FC = ({ onClick={() => onScreenSelect(SettingsScreens.PrivacyLastSeen)} >
- {lang('LastSeenTitle')} + {oldLang('LastSeenTitle')} {getVisibilityValue(privacy.lastSeen)} @@ -225,7 +236,7 @@ const SettingsPrivacy: FC = ({ onClick={() => onScreenSelect(SettingsScreens.PrivacyProfilePhoto)} >
- {lang('PrivacyProfilePhotoTitle')} + {oldLang('PrivacyProfilePhotoTitle')} {getVisibilityValue(privacy.profilePhoto)} @@ -238,7 +249,7 @@ const SettingsPrivacy: FC = ({ onClick={() => onScreenSelect(SettingsScreens.PrivacyBio)} >
- {lang('PrivacyBio')} + {oldLang('PrivacyBio')} {getVisibilityValue(privacy.bio)} @@ -251,12 +262,25 @@ const SettingsPrivacy: FC = ({ onClick={() => onScreenSelect(SettingsScreens.PrivacyBirthday)} >
- {lang('PrivacyBirthday')} + {oldLang('PrivacyBirthday')} {getVisibilityValue(privacy.birthday)}
+ onScreenSelect(SettingsScreens.PrivacyGifts)} + > +
+ {lang('PrivacyGifts')} + + {getVisibilityValue(privacy.gifts)} + +
+
= ({ onClick={() => onScreenSelect(SettingsScreens.PrivacyForwarding)} >
- {lang('PrivacyForwardsTitle')} + {oldLang('PrivacyForwardsTitle')} {getVisibilityValue(privacy.forwards)} @@ -277,7 +301,7 @@ const SettingsPrivacy: FC = ({ onClick={() => onScreenSelect(SettingsScreens.PrivacyPhoneCall)} >
- {lang('WhoCanCallMe')} + {oldLang('WhoCanCallMe')} {getVisibilityValue(privacy.phoneCall)} @@ -292,7 +316,7 @@ const SettingsPrivacy: FC = ({ onClick={() => onScreenSelect(SettingsScreens.PrivacyVoiceMessages)} >
- {lang('PrivacyVoiceMessagesTitle')} + {oldLang('PrivacyVoiceMessagesTitle')} {getVisibilityValue(privacy.voiceMessages)} @@ -306,11 +330,11 @@ const SettingsPrivacy: FC = ({ onClick={() => onScreenSelect(SettingsScreens.PrivacyMessages)} >
- {lang('PrivacyMessagesTitle')} + {oldLang('PrivacyMessagesTitle')} {shouldNewNonContactPeersRequirePremium - ? lang('PrivacyMessagesContactsAndPremium') - : lang('P2PEverybody')} + ? oldLang('PrivacyMessagesContactsAndPremium') + : oldLang('P2PEverybody')}
@@ -321,7 +345,7 @@ const SettingsPrivacy: FC = ({ onClick={() => onScreenSelect(SettingsScreens.PrivacyGroupChats)} >
- {lang('WhoCanAddMe')} + {oldLang('WhoCanAddMe')} {getVisibilityValue(privacy.chatInvite)} @@ -331,12 +355,12 @@ const SettingsPrivacy: FC = ({ {canChangeSensitive && (
-

- {lang('lng_settings_sensitive_title')} +

+ {oldLang('lng_settings_sensitive_title')}

= ({ {canDisplayAutoarchiveSetting && (
-

- {lang('NewChatsFromNonContacts')} +

+ {oldLang('NewChatsFromNonContacts')}

@@ -359,11 +383,11 @@ const SettingsPrivacy: FC = ({ )}
-

- {lang('lng_settings_window_system')} +

+ {oldLang('lng_settings_window_system')}

diff --git a/src/components/left/settings/SettingsPrivacyVisibility.tsx b/src/components/left/settings/SettingsPrivacyVisibility.tsx index ed1ef108c..fe5082a3b 100644 --- a/src/components/left/settings/SettingsPrivacyVisibility.tsx +++ b/src/components/left/settings/SettingsPrivacyVisibility.tsx @@ -3,13 +3,14 @@ import React, { memo, useCallback, useMemo } from '../../../lib/teact/teact'; import { getActions, withGlobal } from '../../../global'; import type { ApiPhoto } from '../../../api/types'; -import type { ApiPrivacySettings } from '../../../types'; +import type { ApiPrivacySettings, BotsPrivacyType } from '../../../types'; import { SettingsScreens } from '../../../types'; import { selectIsCurrentUserPremium, selectUserFullInfo } from '../../../global/selectors'; import { getPrivacyKey } from './helpers/privacy'; import useHistoryBack from '../../../hooks/useHistoryBack'; +import useLang from '../../../hooks/useLang'; import useLastCallback from '../../../hooks/useLastCallback'; import useOldLang from '../../../hooks/useOldLang'; @@ -106,18 +107,19 @@ function PrivacySubsection({ onScreenSelect: (screen: SettingsScreens) => void; }) { const { setPrivacyVisibility } = getActions(); - const lang = useOldLang(); + const oldLang = useOldLang(); + const lang = useLang(); const visibilityOptions = useMemo(() => { const hasNobody = screen !== SettingsScreens.PrivacyAddByPhone; const options = [ - { value: 'everybody', label: lang('P2PEverybody') }, + { value: 'everybody', label: oldLang('P2PEverybody') }, { value: 'contacts', label: isPremiumRequired ? ( - + ) : ( - lang('P2PContacts') + oldLang('P2PContacts') ), hidden: isPremiumRequired, }, @@ -127,15 +129,15 @@ function PrivacySubsection({ options.push({ value: 'nobody', label: isPremiumRequired ? ( - + ) : ( - lang('P2PNobody') + oldLang('P2PNobody') ), hidden: isPremiumRequired, }); } return options; - }, [lang, screen, isPremiumRequired]); + }, [oldLang, screen, isPremiumRequired]); const primaryExceptionLists = useMemo(() => { if (screen === SettingsScreens.PrivacyAddByPhone) { @@ -155,65 +157,81 @@ function PrivacySubsection({ const descriptionText = useMemo(() => { switch (screen) { + case SettingsScreens.PrivacyGifts: + return lang('PrivacyGiftsInfo'); case SettingsScreens.PrivacyLastSeen: - return lang('CustomHelp'); + return oldLang('CustomHelp'); case SettingsScreens.PrivacyAddByPhone: { - return privacy?.visibility === 'everybody' ? lang('PrivacyPhoneInfo') : lang('PrivacyPhoneInfo3'); + return privacy?.visibility === 'everybody' ? oldLang('PrivacyPhoneInfo') : oldLang('PrivacyPhoneInfo3'); } case SettingsScreens.PrivacyVoiceMessages: - return lang('PrivacyVoiceMessagesInfo'); + return oldLang('PrivacyVoiceMessagesInfo'); default: return undefined; } - }, [lang, screen, privacy]); + }, [oldLang, lang, screen, privacy]); const headerText = useMemo(() => { switch (screen) { case SettingsScreens.PrivacyPhoneNumber: - return lang('PrivacyPhoneTitle'); + return oldLang('PrivacyPhoneTitle'); case SettingsScreens.PrivacyAddByPhone: - return lang('PrivacyPhoneTitle2'); + return oldLang('PrivacyPhoneTitle2'); case SettingsScreens.PrivacyLastSeen: - return lang('LastSeenTitle'); + return oldLang('LastSeenTitle'); case SettingsScreens.PrivacyProfilePhoto: - return lang('PrivacyProfilePhotoTitle'); + return oldLang('PrivacyProfilePhotoTitle'); case SettingsScreens.PrivacyBio: - return lang('PrivacyBioTitle'); + return oldLang('PrivacyBioTitle'); case SettingsScreens.PrivacyBirthday: - return lang('PrivacyBirthdayTitle'); + return oldLang('PrivacyBirthdayTitle'); + case SettingsScreens.PrivacyGifts: + return lang('PrivacyGiftsTitle'); case SettingsScreens.PrivacyForwarding: - return lang('PrivacyForwardsTitle'); + return oldLang('PrivacyForwardsTitle'); case SettingsScreens.PrivacyVoiceMessages: - return lang('PrivacyVoiceMessagesTitle'); + return oldLang('PrivacyVoiceMessagesTitle'); case SettingsScreens.PrivacyGroupChats: - return lang('WhoCanAddMe'); + return oldLang('WhoCanAddMe'); case SettingsScreens.PrivacyPhoneCall: - return lang('WhoCanCallMe'); + return oldLang('WhoCanCallMe'); case SettingsScreens.PrivacyPhoneP2P: - return lang('PrivacyP2P'); + return oldLang('PrivacyP2P'); default: return undefined; } - }, [lang, screen]); + }, [oldLang, lang, screen]); - const prepareSubtitle = useLastCallback((userIds?: string[], chatIds?: string[], shouldAllowPremium?: boolean) => { - const userIdsCount = userIds?.length || 0; - const chatIdsCount = chatIds?.length || 0; + const prepareSubtitle = useLastCallback( + (userIds?: string[], chatIds?: string[], shouldAllowPremium?: boolean, botsPrivacy?: BotsPrivacyType) => { + const userIdsCount = userIds?.length || 0; + const chatIdsCount = chatIds?.length || 0; + const isAllowBots = botsPrivacy === 'allow'; + const hasPeers = userIdsCount || chatIdsCount; - if (!userIdsCount && !chatIdsCount) { - return shouldAllowPremium ? lang('PrivacyPremium') : lang('EditAdminAddUsers'); - } else if (shouldAllowPremium) { - return lang('ContactsAndPremium'); - } + if (!hasPeers && !isAllowBots) { + return shouldAllowPremium ? oldLang('PrivacyPremium') : oldLang('EditAdminAddUsers'); + } else if (shouldAllowPremium) { + return oldLang('ContactsAndPremium'); + } - const userCountString = userIdsCount > 0 ? lang('Users', userIdsCount) : undefined; - const chatCountString = chatIdsCount > 0 ? lang('Chats', chatIdsCount) : undefined; + const userCountString = userIdsCount > 0 ? oldLang('Users', userIdsCount) : undefined; + const chatCountString = chatIdsCount > 0 ? oldLang('Chats', chatIdsCount) : undefined; - return [userCountString, chatCountString].filter(Boolean).join(', '); - }); + const botPrivacyString = isAllowBots ? lang('PrivacyValueBots') : ''; + const peersString = lang.conjunction([userCountString, chatCountString].filter(Boolean)); + + return [botPrivacyString, peersString].filter(Boolean).join(' '); + }, + ); const allowedString = useMemo(() => { - return prepareSubtitle(privacy?.allowUserIds, privacy?.allowChatIds, privacy?.shouldAllowPremium); + return prepareSubtitle( + privacy?.allowUserIds, + privacy?.allowChatIds, + privacy?.shouldAllowPremium, + privacy?.botsPrivacy, + ); }, [privacy]); const blockString = useMemo(() => { @@ -239,6 +257,8 @@ function PrivacySubsection({ return SettingsScreens.PrivacyBioAllowedContacts; case SettingsScreens.PrivacyBirthday: return SettingsScreens.PrivacyBirthdayAllowedContacts; + case SettingsScreens.PrivacyGifts: + return SettingsScreens.PrivacyGiftsAllowedContacts; case SettingsScreens.PrivacyForwarding: return SettingsScreens.PrivacyForwardingAllowedContacts; case SettingsScreens.PrivacyPhoneCall: @@ -264,6 +284,8 @@ function PrivacySubsection({ return SettingsScreens.PrivacyBioDeniedContacts; case SettingsScreens.PrivacyBirthday: return SettingsScreens.PrivacyBirthdayDeniedContacts; + case SettingsScreens.PrivacyGifts: + return SettingsScreens.PrivacyGiftsDeniedContacts; case SettingsScreens.PrivacyForwarding: return SettingsScreens.PrivacyForwardingDeniedContacts; case SettingsScreens.PrivacyPhoneCall: @@ -280,7 +302,7 @@ function PrivacySubsection({ return ( <>
-

{headerText}

+

{headerText}

{descriptionText && ( -

{descriptionText}

+

{descriptionText}

)}
{!isPremiumRequired && (primaryExceptionLists.shouldShowAllowed || primaryExceptionLists.shouldShowDenied) && (
-

- {lang('PrivacyExceptions')} +

+ {oldLang('PrivacyExceptions')}

{primaryExceptionLists.shouldShowAllowed && (
- {lang('AlwaysAllow')} + {oldLang('AlwaysAllow')} {allowedString}
@@ -321,7 +343,7 @@ function PrivacySubsection({ }} >
- {lang('NeverAllow')} + {oldLang('NeverAllow')} {blockString}
@@ -367,6 +389,10 @@ export default memo(withGlobal( primaryPrivacy = privacy.birthday; break; + case SettingsScreens.PrivacyGifts: + primaryPrivacy = privacy.gifts; + break; + case SettingsScreens.PrivacyPhoneP2P: case SettingsScreens.PrivacyPhoneCall: primaryPrivacy = privacy.phoneCall; diff --git a/src/components/left/settings/SettingsPrivacyVisibilityExceptionList.tsx b/src/components/left/settings/SettingsPrivacyVisibilityExceptionList.tsx index e58ee98cc..9a4c04d08 100644 --- a/src/components/left/settings/SettingsPrivacyVisibilityExceptionList.tsx +++ b/src/components/left/settings/SettingsPrivacyVisibilityExceptionList.tsx @@ -5,7 +5,7 @@ import React, { import { getActions, getGlobal, withGlobal } from '../../../global'; import type { GlobalState } from '../../../global/types'; -import type { ApiPrivacySettings, CustomPeerType } from '../../../types'; +import type { ApiPrivacySettings, CustomPeerType, UniqueCustomPeer } from '../../../types'; import { SettingsScreens } from '../../../types'; import { ALL_FOLDER_ID, ARCHIVED_FOLDER_ID, SERVICE_NOTIFICATIONS_USER_ID } from '../../../config'; @@ -18,6 +18,7 @@ import { getPrivacyKey } from './helpers/privacy'; import { useFolderManagerForOrderedIds } from '../../../hooks/useFolderManager'; import useHistoryBack from '../../../hooks/useHistoryBack'; +import useLang from '../../../hooks/useLang'; import useOldLang from '../../../hooks/useOldLang'; import PeerPicker from '../../common/pickers/PeerPicker'; @@ -26,6 +27,7 @@ import FloatingActionButton from '../../ui/FloatingActionButton'; export type OwnProps = { isAllowList?: boolean; withPremiumCategory?: boolean; + withMiniAppsCategory?: boolean; screen: SettingsScreens; isActive?: boolean; onScreenSelect: (screen: SettingsScreens) => void; @@ -42,6 +44,7 @@ const PREMIUM_CATEGORY = [CUSTOM_PEER_PREMIUM]; const SettingsPrivacyVisibilityExceptionList: FC = ({ isAllowList, withPremiumCategory, + withMiniAppsCategory, screen, isActive, currentUserId, @@ -51,7 +54,23 @@ const SettingsPrivacyVisibilityExceptionList: FC = ({ }) => { const { setPrivacySettings } = getActions(); - const lang = useOldLang(); + const oldLang = useOldLang(); + const lang = useLang(); + + const customPeerBots : UniqueCustomPeer = useMemo(() => { + return { + isCustomPeer: true, + type: 'bots', + title: lang('PrivacyValueBots'), + avatarIcon: 'bots', + isAvatarSquare: true, + peerColorId: 6, + }; + }, [lang]); + + const miniAppsCategory = useMemo(() => { + return [customPeerBots]; + }, [customPeerBots]); const selectedContactIds = useMemo(() => { if (!settings) { @@ -68,9 +87,10 @@ const SettingsPrivacyVisibilityExceptionList: FC = ({ if (!settings) { return []; } - - return [settings.shouldAllowPremium ? CUSTOM_PEER_PREMIUM.type : undefined].filter(Boolean); - }, [settings]); + if (settings.shouldAllowPremium) { return [CUSTOM_PEER_PREMIUM.type]; } + if (settings.botsPrivacy === 'allow' && isAllowList) { return [customPeerBots.type]; } + return []; + }, [settings, isAllowList, customPeerBots]); const [searchQuery, setSearchQuery] = useState(''); const [isSubmitShown, setIsSubmitShown] = useState(false); const [newSelectedContactIds, setNewSelectedContactIds] = useState(selectedContactIds); @@ -100,16 +120,16 @@ const SettingsPrivacyVisibilityExceptionList: FC = ({ return chatId !== currentUserId && chatId !== SERVICE_NOTIFICATIONS_USER_ID && !isChannel && !isDeleted; }); - const filteredChats = filterChatsByName(lang, chatIds, chatsById, searchQuery); + const filteredChats = filterChatsByName(oldLang, chatIds, chatsById, searchQuery); // Show only relevant items if (searchQuery) return filteredChats; return unique([ ...selectedContactIds, - ...filterChatsByName(lang, chatIds, chatsById, searchQuery), + ...filterChatsByName(oldLang, chatIds, chatsById, searchQuery), ]); - }, [folderAllOrderedIds, folderArchivedOrderedIds, selectedContactIds, lang, searchQuery, currentUserId]); + }, [folderAllOrderedIds, folderArchivedOrderedIds, selectedContactIds, oldLang, searchQuery, currentUserId]); const handleSelectedCategoriesChange = useCallback((value: CustomPeerType[]) => { setNewSelectedCategoryTypes(value); @@ -127,25 +147,41 @@ const SettingsPrivacyVisibilityExceptionList: FC = ({ isAllowList: Boolean(isAllowList), updatedIds: newSelectedContactIds, isPremiumAllowed: newSelectedCategoryTypes.includes(CUSTOM_PEER_PREMIUM.type) || undefined, + botsPrivacy: (!withMiniAppsCategory) ? 'none' + : (newSelectedCategoryTypes.includes(customPeerBots.type) ? 'allow' : 'disallow'), }); onScreenSelect(SettingsScreens.Privacy); - }, [isAllowList, newSelectedCategoryTypes, newSelectedContactIds, onScreenSelect, screen]); + }, [ + isAllowList, + withMiniAppsCategory, + newSelectedCategoryTypes, + newSelectedContactIds, + onScreenSelect, + screen, + customPeerBots, + ]); useHistoryBack({ isActive, onBack: onReset, }); + function getCustomCategory() { + if (withPremiumCategory) return PREMIUM_CATEGORY; + if (withMiniAppsCategory && isAllowList) return miniAppsCategory; + return undefined; + } + return (
= ({ @@ -187,6 +223,9 @@ function getCurrentPrivacySettings(global: GlobalState, screen: SettingsScreens) case SettingsScreens.PrivacyBirthdayAllowedContacts: case SettingsScreens.PrivacyBirthdayDeniedContacts: return privacy.birthday; + case SettingsScreens.PrivacyGiftsAllowedContacts: + case SettingsScreens.PrivacyGiftsDeniedContacts: + return privacy.gifts; case SettingsScreens.PrivacyPhoneCallAllowedContacts: case SettingsScreens.PrivacyPhoneCallDeniedContacts: return privacy.phoneCall; diff --git a/src/components/left/settings/helpers/privacy.ts b/src/components/left/settings/helpers/privacy.ts index 9249d4c73..a9b123bf3 100644 --- a/src/components/left/settings/helpers/privacy.ts +++ b/src/components/left/settings/helpers/privacy.ts @@ -23,6 +23,10 @@ export function getPrivacyKey(screen: SettingsScreens): ApiPrivacyKey | undefine case SettingsScreens.PrivacyBirthdayAllowedContacts: case SettingsScreens.PrivacyBirthdayDeniedContacts: return 'birthday'; + case SettingsScreens.PrivacyGifts: + case SettingsScreens.PrivacyGiftsAllowedContacts: + case SettingsScreens.PrivacyGiftsDeniedContacts: + return 'gifts'; case SettingsScreens.PrivacyForwarding: case SettingsScreens.PrivacyForwardingAllowedContacts: case SettingsScreens.PrivacyForwardingDeniedContacts: diff --git a/src/global/actions/api/settings.ts b/src/global/actions/api/settings.ts index c31ca6ed6..8648b1dd4 100644 --- a/src/global/actions/api/settings.ts +++ b/src/global/actions/api/settings.ts @@ -396,6 +396,7 @@ addActionHandler('loadPrivacySettings', async (global): Promise => { callApi('fetchPrivacySettings', 'voiceMessages'), callApi('fetchPrivacySettings', 'bio'), callApi('fetchPrivacySettings', 'birthday'), + callApi('fetchPrivacySettings', 'gifts'), ]); if (result.some((e) => e === undefined)) { @@ -414,6 +415,7 @@ addActionHandler('loadPrivacySettings', async (global): Promise => { voiceMessagesSettings, bioSettings, birthdaySettings, + giftsSettings, ] = result as { rules: ApiPrivacySettings; }[]; @@ -436,6 +438,7 @@ addActionHandler('loadPrivacySettings', async (global): Promise => { voiceMessages: voiceMessagesSettings.rules, bio: bioSettings.rules, birthday: birthdaySettings.rules, + gifts: giftsSettings.rules, }, }, }; @@ -477,6 +480,7 @@ addActionHandler('setPrivacyVisibility', async (global, actions, payload): Promi visibility, allowedIds: [...settings.allowUserIds, ...settings.allowChatIds], blockedIds: [...settings.blockUserIds, ...settings.blockChatIds], + botsPrivacy: settings.botsPrivacy, }); const result = await callApi('setPrivacySettings', privacyKey, rules); @@ -502,7 +506,7 @@ addActionHandler('setPrivacyVisibility', async (global, actions, payload): Promi addActionHandler('setPrivacySettings', async (global, actions, payload): Promise => { const { - privacyKey, isAllowList, updatedIds, isPremiumAllowed, + privacyKey, isAllowList, updatedIds, isPremiumAllowed, botsPrivacy, } = payload!; const { privacy: { [privacyKey]: settings }, @@ -518,6 +522,7 @@ addActionHandler('setPrivacySettings', async (global, actions, payload): Promise shouldAllowPremium: isPremiumAllowed, allowedIds: isAllowList ? updatedIds : [...settings.allowUserIds, ...settings.allowChatIds], blockedIds: !isAllowList ? updatedIds : [...settings.blockUserIds, ...settings.blockChatIds], + botsPrivacy, }); const result = await callApi('setPrivacySettings', privacyKey, rules); diff --git a/src/global/actions/api/stories.ts b/src/global/actions/api/stories.ts index 706cbab1f..0c1176963 100644 --- a/src/global/actions/api/stories.ts +++ b/src/global/actions/api/stories.ts @@ -241,12 +241,13 @@ addActionHandler('toggleStoryPinnedToTop', async (global, actions, payload): Pro const isRemoving = oldPinnedIds.includes(storyId); const newPinnedIds = isRemoving ? oldPinnedIds.filter((id) => id !== storyId) : [...oldPinnedIds, storyId]; + global = getGlobal(); global = { - ...getGlobal(), + ...global, stories: { - ...getGlobal().stories, + ...global.stories, byPeerId: { - ...getGlobal().stories.byPeerId, + ...global.stories.byPeerId, [peerId]: { ...peerStories, pinnedIds: newPinnedIds.sort((a, b) => b - a), @@ -520,6 +521,7 @@ addActionHandler('editStoryPrivacy', (global, actions, payload): ActionReturnTyp isUnspecified: privacy.isUnspecified, allowedIds, blockedIds, + botsPrivacy: 'none', }); void callApi('editStoryPrivacy', { diff --git a/src/global/helpers/misc.ts b/src/global/helpers/misc.ts index b3f0b6f41..4738ceaf8 100644 --- a/src/global/helpers/misc.ts +++ b/src/global/helpers/misc.ts @@ -1,4 +1,4 @@ -import type { ApiInputPrivacyRules, PrivacyVisibility } from '../../types'; +import type { ApiInputPrivacyRules, BotsPrivacyType, PrivacyVisibility } from '../../types'; import type { GlobalState } from '../types'; import { partition } from '../../util/iteratees'; @@ -10,12 +10,14 @@ export function buildApiInputPrivacyRules(global: GlobalState, { allowedIds, blockedIds, shouldAllowPremium, + botsPrivacy, }: { visibility: PrivacyVisibility; isUnspecified?: boolean; allowedIds: string[]; blockedIds: string[]; shouldAllowPremium?: true; + botsPrivacy: BotsPrivacyType; }): ApiInputPrivacyRules { const { users: { byId: usersById }, @@ -33,6 +35,7 @@ export function buildApiInputPrivacyRules(global: GlobalState, { blockedUsers: blockedUserIds.map((userId) => usersById[userId]).filter(Boolean), blockedChats: blockedChatIds.map((chatId) => chatsById[chatId]).filter(Boolean), shouldAllowPremium, + botsPrivacy, }; return rules; diff --git a/src/global/types.ts b/src/global/types.ts index bbb539e42..cb71b912f 100644 --- a/src/global/types.ts +++ b/src/global/types.ts @@ -106,6 +106,7 @@ import type { ApiPrivacyKey, ApiPrivacySettings, AudioOrigin, + BotsPrivacyType, ChatCreationProgress, ChatMediaSearchParams, EmojiKeywords, @@ -1492,6 +1493,7 @@ export interface ActionPayloads { isAllowList: boolean; updatedIds: string[]; isPremiumAllowed?: true; + botsPrivacy: BotsPrivacyType; }; loadNotificationExceptions: undefined; setThemeSettings: { theme: ThemeKey } & Partial; diff --git a/src/types/index.ts b/src/types/index.ts index 27515e9ed..efbe8622e 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -134,6 +134,8 @@ export interface ISettings extends NotifySettings, Record { shouldSkipWebAppCloseConfirmation: boolean; } +export type BotsPrivacyType = 'allow' | 'disallow' | 'none'; + export interface ApiPrivacySettings { visibility: PrivacyVisibility; isUnspecified?: boolean; @@ -142,6 +144,7 @@ export interface ApiPrivacySettings { blockUserIds: string[]; blockChatIds: string[]; shouldAllowPremium?: true; + botsPrivacy: BotsPrivacyType; } export interface ApiInputPrivacyRules { @@ -152,6 +155,7 @@ export interface ApiInputPrivacyRules { blockedUsers?: ApiUser[]; blockedChats?: ApiChat[]; shouldAllowPremium?: true; + botsPrivacy: BotsPrivacyType; } export type IAnchorPosition = { @@ -183,6 +187,7 @@ export enum SettingsScreens { PrivacyProfilePhoto, PrivacyBio, PrivacyBirthday, + PrivacyGifts, PrivacyPhoneCall, PrivacyPhoneP2P, PrivacyForwarding, @@ -199,6 +204,8 @@ export enum SettingsScreens { PrivacyBioDeniedContacts, PrivacyBirthdayAllowedContacts, PrivacyBirthdayDeniedContacts, + PrivacyGiftsAllowedContacts, + PrivacyGiftsDeniedContacts, PrivacyPhoneCallAllowedContacts, PrivacyPhoneCallDeniedContacts, PrivacyPhoneP2PAllowedContacts, @@ -407,7 +414,7 @@ export type MiddleSearchResults = { }; export type ApiPrivacyKey = 'phoneNumber' | 'addByPhone' | 'lastSeen' | 'profilePhoto' | 'voiceMessages' | -'forwards' | 'chatInvite' | 'phoneCall' | 'phoneP2P' | 'bio' | 'birthday'; +'forwards' | 'chatInvite' | 'phoneCall' | 'phoneP2P' | 'bio' | 'birthday' | 'gifts'; export type PrivacyVisibility = 'everybody' | 'contacts' | 'closeFriends' | 'nonContacts' | 'nobody'; export interface LoadingState { diff --git a/src/types/language.d.ts b/src/types/language.d.ts index f0eb9203a..902d9aaab 100644 --- a/src/types/language.d.ts +++ b/src/types/language.d.ts @@ -1159,6 +1159,11 @@ export interface LangPair { 'VideoConversionView': undefined; 'BotSuggestedStatusTitle': undefined; 'BotSuggestedStatusUpdated': undefined; + 'PrivacyGifts': undefined; + 'PrivacyGiftsTitle': undefined; + 'PrivacyGiftsInfo': undefined; + 'PrivacyValueBots': undefined; + 'CustomShareGiftsInfo': undefined; } export interface LangPairWithVariables {