Do not show avatars for call notifications when "no name or content" setting is enabled

This commit is contained in:
yash-signal
2025-05-20 18:34:53 -05:00
committed by GitHub
parent ffb2f3cb7e
commit 388e145ed6
2 changed files with 75 additions and 64 deletions

View File

@@ -3834,17 +3834,21 @@ export class CallingClass {
): Promise<void> {
let notificationTitle: string;
let notificationMessage: string;
let url: string | undefined;
let absolutePath: string | undefined;
switch (notificationService.getNotificationSetting()) {
case NotificationSetting.Off:
case NotificationSetting.Off: {
return;
case NotificationSetting.NoNameOrMessage:
}
case NotificationSetting.NoNameOrMessage: {
notificationTitle = FALLBACK_NOTIFICATION_TITLE;
notificationMessage = window.i18n(
'icu:calling__call-notification__started-by-someone'
);
break;
default:
}
default: {
// These fallbacks exist just in case something unexpected goes wrong.
notificationTitle =
conversation?.getTitle() || FALLBACK_NOTIFICATION_TITLE;
@@ -3853,11 +3857,13 @@ export class CallingClass {
name: creatorConversation.getTitle(),
})
: window.i18n('icu:calling__call-notification__started-by-someone');
const iconData = await conversation.getAvatarOrIdenticon();
url = iconData.url;
absolutePath = iconData.absolutePath;
break;
}
}
const { url, absolutePath } = await conversation.getAvatarOrIdenticon();
notificationService.notify({
conversationId: conversation.id,
iconPath: absolutePath,
@@ -3870,6 +3876,69 @@ export class CallingClass {
});
}
async notifyForCall(
conversationId: string,
title: string,
isVideoCall: boolean
): Promise<void> {
const shouldNotify =
!window.SignalContext.activeWindowService.isActive() &&
window.storage.get('call-system-notification', true);
if (!shouldNotify) {
return;
}
const conversation = window.ConversationController.get(conversationId);
if (!conversation) {
log.error('notifyForCall: conversation not found');
return;
}
let notificationTitle: string;
let url: string | undefined;
let absolutePath: string | undefined;
const notificationSetting = notificationService.getNotificationSetting();
switch (notificationSetting) {
case NotificationSetting.Off: {
return;
}
case NotificationSetting.NoNameOrMessage: {
notificationTitle = FALLBACK_NOTIFICATION_TITLE;
break;
}
case NotificationSetting.NameOnly:
case NotificationSetting.NameAndMessage: {
notificationTitle = title;
const iconData = await conversation.getAvatarOrIdenticon();
url = iconData.url;
absolutePath = iconData.absolutePath;
break;
}
default: {
log.error(missingCaseError(notificationSetting));
notificationTitle = FALLBACK_NOTIFICATION_TITLE;
break;
}
}
notificationService.notify({
conversationId,
title: notificationTitle,
iconPath: absolutePath,
iconUrl: url,
message: isVideoCall
? window.i18n('icu:incomingVideoCall')
: window.i18n('icu:incomingAudioCall'),
sentAt: 0,
// The ringtone plays so we don't need sound for the notification
silent: true,
type: NotificationType.IncomingCall,
});
}
#areAnyCallsActiveOrRinging(): boolean {
return this.#reduxInterface?.areAnyCallsActiveOrRinging() ?? false;
}

View File

@@ -12,12 +12,6 @@ import { CallManager } from '../../components/CallManager';
import { isConversationTooBigToRing as getIsConversationTooBigToRing } from '../../conversations/isConversationTooBigToRing';
import * as log from '../../logging/log';
import { calling as callingService } from '../../services/calling';
import {
FALLBACK_NOTIFICATION_TITLE,
NotificationSetting,
NotificationType,
notificationService,
} from '../../services/notifications';
import {
bounceAppIconStart,
bounceAppIconStop,
@@ -35,7 +29,6 @@ import type {
import { CallState } from '../../types/Calling';
import { CallMode } from '../../types/CallDisposition';
import type { AciString } from '../../types/ServiceId';
import { strictAssert } from '../../util/assert';
import { callLinkToConversation } from '../../util/callLinks';
import { callingTones } from '../../util/callingTones';
import { missingCaseError } from '../../util/missingCaseError';
@@ -63,62 +56,11 @@ import { getActiveProfile } from '../selectors/notificationProfiles';
function renderDeviceSelection(): JSX.Element {
return <SmartCallingDeviceSelection />;
}
function getCallSystemNotification() {
return window.storage.get('call-system-notification', true);
}
const getGroupCallVideoFrameSource =
callingService.getGroupCallVideoFrameSource.bind(callingService);
async function notifyForCall(
conversationId: string,
title: string,
isVideoCall: boolean
): Promise<void> {
const shouldNotify =
!window.SignalContext.activeWindowService.isActive() &&
getCallSystemNotification();
if (!shouldNotify) {
return;
}
let notificationTitle: string;
const notificationSetting = notificationService.getNotificationSetting();
switch (notificationSetting) {
case NotificationSetting.Off:
case NotificationSetting.NoNameOrMessage:
notificationTitle = FALLBACK_NOTIFICATION_TITLE;
break;
case NotificationSetting.NameOnly:
case NotificationSetting.NameAndMessage:
notificationTitle = title;
break;
default:
log.error(missingCaseError(notificationSetting));
notificationTitle = FALLBACK_NOTIFICATION_TITLE;
break;
}
const conversation = window.ConversationController.get(conversationId);
strictAssert(conversation, 'notifyForCall: conversation not found');
const { url, absolutePath } = await conversation.getAvatarOrIdenticon();
notificationService.notify({
conversationId,
title: notificationTitle,
iconPath: absolutePath,
iconUrl: url,
message: isVideoCall
? window.i18n('icu:incomingVideoCall')
: window.i18n('icu:incomingAudioCall'),
sentAt: 0,
// The ringtone plays so we don't need sound for the notification
silent: true,
type: NotificationType.IncomingCall,
});
}
const notifyForCall = callingService.notifyForCall.bind(callingService);
function setLocalPreviewContainer(container: HTMLDivElement | null): void {
callingService.setLocalPreviewContainer(container);