2022-08-02 19:31:55 +00:00
|
|
|
// Copyright 2022 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import type { ConversationAttributesType } from '../model-types.d';
|
|
|
|
import type { ConversationModel } from '../models/conversations';
|
|
|
|
import type { ConversationType } from '../state/ducks/conversations';
|
|
|
|
import { isInSystemContacts } from './isInSystemContacts';
|
2023-12-13 23:58:56 +00:00
|
|
|
import { isSignalConversation } from './isSignalConversation';
|
2022-08-04 20:26:29 +00:00
|
|
|
import { isDirectConversation } from './whatTypeOfConversation';
|
2022-11-17 02:15:26 +00:00
|
|
|
import { isConversationEverUnregistered } from './isConversationUnregistered';
|
2023-12-13 23:58:56 +00:00
|
|
|
import { isBlocked } from './isBlocked';
|
2022-08-02 19:31:55 +00:00
|
|
|
|
|
|
|
export function isSignalConnection(
|
|
|
|
conversation: ConversationType | ConversationAttributesType
|
|
|
|
): boolean {
|
2022-08-04 20:26:29 +00:00
|
|
|
return (
|
|
|
|
isDirectConversation(conversation) &&
|
2022-11-17 02:15:26 +00:00
|
|
|
(conversation.profileSharing || isInSystemContacts(conversation)) &&
|
2023-08-16 20:54:39 +00:00
|
|
|
conversation.serviceId !== undefined &&
|
2023-12-13 23:58:56 +00:00
|
|
|
('isBlocked' in conversation
|
|
|
|
? !conversation.isBlocked
|
|
|
|
: !isBlocked(conversation)) &&
|
|
|
|
!isSignalConversation(conversation) &&
|
2022-11-17 02:15:26 +00:00
|
|
|
!isConversationEverUnregistered(conversation)
|
2022-08-04 20:26:29 +00:00
|
|
|
);
|
2022-08-02 19:31:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function getSignalConnections(): Array<ConversationModel> {
|
|
|
|
return window
|
|
|
|
.getConversations()
|
|
|
|
.filter(conversation => isSignalConnection(conversation.attributes));
|
|
|
|
}
|