signal-desktop/ts/jobs/helpers/getValidRecipients.ts
Scott Nonnenberg 783c71999a
Send call messages with conversationJobQueue
Co-authored-by: trevor-signal <trevor@signal.org>
2024-04-16 14:55:09 -07:00

40 lines
1 KiB
TypeScript

// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { isNotNil } from '../../util/isNotNil';
import type { LoggerType } from '../../types/Logging';
import type { ServiceIdString } from '../../types/ServiceId';
export function getValidRecipients(
recipients: Array<string>,
options: {
logId: string;
log: LoggerType;
}
): Array<ServiceIdString> {
const { log, logId } = options;
return recipients
.map(id => {
const recipient = window.ConversationController.get(id);
if (!recipient) {
return undefined;
}
if (recipient.isUnregistered()) {
log.warn(
`${logId}: dropping unregistered recipient ${recipient.idForLogging()}`
);
return undefined;
}
if (recipient.isBlocked()) {
log.warn(
`${logId}: dropping blocked recipient ${recipient.idForLogging()}`
);
return undefined;
}
return recipient.getSendTarget();
})
.filter(isNotNil);
}