Skip to content

Commit e037a48

Browse files
otto-the-botthisisamir98
authored andcommitted
feat: Enable on prem customer to disallow link previews regarless of desktop setting (#19267) (#19268)
Co-authored-by: Amir Ghezelbash <[email protected]>
1 parent e98ea40 commit e037a48

File tree

4 files changed

+28
-18
lines changed

4 files changed

+28
-18
lines changed

server/config/client.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export function generateConfig(params: ConfigGeneratorParams, env: Env) {
4949
ALLOWED_FILE_UPLOAD_EXTENSIONS: (env.FEATURE_ALLOWED_FILE_UPLOAD_EXTENSIONS || '*')
5050
.split(',')
5151
.map(extension => extension.trim()),
52+
ALLOW_LINK_PREVIEWS: env.FEATURE_ALLOW_LINK_PREVIEWS == 'true',
5253
APPLOCK_SCHEDULED_TIMEOUT: env.FEATURE_APPLOCK_SCHEDULED_TIMEOUT
5354
? Number(env.FEATURE_APPLOCK_SCHEDULED_TIMEOUT)
5455
: null,

server/config/env.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ export type Env = {
8787
/** Accepted file extensions for asset upload (e.g. ".txt,.jpg" or "*") */
8888
FEATURE_ALLOWED_FILE_UPLOAD_EXTENSIONS: string;
8989

90+
FEATURE_ALLOW_LINK_PREVIEWS: string;
91+
9092
/** will enable the MLS protocol */
9193
FEATURE_USE_CORE_CRYPTO?: string;
9294

src/script/conversation/MessageRepository.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ import {AudioRepository} from '../audio/AudioRepository';
7979
import {AudioType} from '../audio/AudioType';
8080
import {ClientState} from '../client/ClientState';
8181
import {PrimaryModal} from '../components/Modals/PrimaryModal';
82+
import {Config} from '../Config';
8283
import {EventBuilder} from '../conversation/EventBuilder';
8384
import {CryptographyRepository} from '../cryptography/CryptographyRepository';
8485
import {PROTO_MESSAGE_TYPE} from '../cryptography/ProtoMessageType';
@@ -410,7 +411,10 @@ export class MessageRepository {
410411

411412
private async handleLinkPreview(textPayload: TextMessagePayload & {messageId: string}) {
412413
// check if the user actually wants to send link previews
413-
if (!this.propertyRepository.getPreference(PROPERTIES_TYPE.PREVIEWS.SEND)) {
414+
if (
415+
!this.propertyRepository.getPreference(PROPERTIES_TYPE.PREVIEWS.SEND) ||
416+
Config.getConfig().FEATURE.ALLOW_LINK_PREVIEWS === false
417+
) {
414418
return;
415419
}
416420

src/script/page/MainContent/panels/preferences/OptionPreferences.tsx

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ const OptionPreferences = ({propertiesRepository, selfUser}: OptionPreferencesPr
136136
];
137137

138138
const isMessageFormatButtonsFlagEnabled = Config.getConfig().FEATURE.ENABLE_MESSAGE_FORMAT_BUTTONS;
139+
const isLinkPreviewsEnabled = Config.getConfig().FEATURE.ALLOW_LINK_PREVIEWS;
139140

140141
return (
141142
<PreferencesPage title={t('preferencesOptions')}>
@@ -270,24 +271,26 @@ const OptionPreferences = ({propertiesRepository, selfUser}: OptionPreferencesPr
270271
</div>
271272
)}
272273

273-
<div className="checkbox-margin">
274-
<Checkbox
275-
tabIndex={TabIndex.FOCUSABLE}
276-
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
277-
saveOptionSendPreviewsPreference(event.target.checked);
278-
}}
279-
checked={optionSendPreviews}
280-
data-uie-name="status-preference-previews-send"
281-
>
282-
<CheckboxLabel htmlFor="status-preference-previews-send">
283-
{t('preferencesOptionsPreviewsSendCheckbox')}
284-
</CheckboxLabel>
285-
</Checkbox>
274+
{isLinkPreviewsEnabled && (
275+
<div className="checkbox-margin">
276+
<Checkbox
277+
tabIndex={TabIndex.FOCUSABLE}
278+
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
279+
saveOptionSendPreviewsPreference(event.target.checked);
280+
}}
281+
checked={optionSendPreviews}
282+
data-uie-name="status-preference-previews-send"
283+
>
284+
<CheckboxLabel htmlFor="status-preference-previews-send">
285+
{t('preferencesOptionsPreviewsSendCheckbox')}
286+
</CheckboxLabel>
287+
</Checkbox>
286288

287-
<p className="preferences-detail preferences-detail-intended">
288-
{t('preferencesOptionsPreviewsSendDetail')}
289-
</p>
290-
</div>
289+
<p className="preferences-detail preferences-detail-intended">
290+
{t('preferencesOptionsPreviewsSendDetail')}
291+
</p>
292+
</div>
293+
)}
291294
</>
292295
)}
293296
</PreferencesSection>

0 commit comments

Comments
 (0)