diff --git a/lib/shared/protocol-names.js b/lib/shared/protocol-names.js new file mode 100644 --- /dev/null +++ b/lib/shared/protocol-names.js @@ -0,0 +1,7 @@ +// @flow + +export const protocolNames = Object.freeze({ + COMM_DM: 'Comm DM', + FARCASTER_DC: 'Farcaster DC', + KEYSERVER: 'Keyserver', +}); diff --git a/lib/shared/threads/protocols/dm-thread-protocol.js b/lib/shared/threads/protocols/dm-thread-protocol.js --- a/lib/shared/threads/protocols/dm-thread-protocol.js +++ b/lib/shared/threads/protocols/dm-thread-protocol.js @@ -60,6 +60,7 @@ } from '../../dm-ops/dm-op-types.js'; import { getIDFromLocalID } from '../../id-utils.js'; import { messageNotifyTypes } from '../../messages/message-spec.js'; +import { protocolNames } from '../../protocol-names.js'; import { createThreadTimestamps, getContainingThreadID, @@ -902,6 +903,10 @@ webChatThreadListIcon: 'lock', threadAncestorLabel: () => 'Local DM', threadSearchHeaderShowsGenesis: false, + protocolIcon: 'lock', + description: + 'Comm DMs are end-to-end encrypted and stored locally on your ' + + 'device for maximum privacy.', }, supportsEncryptedMultimedia: true, @@ -937,6 +942,7 @@ }, supportsBackgroundNotifs: true, viewerCanUpdateOwnRole: false, + protocolName: protocolNames.COMM_DM, }); function pendingThreadType(numberOfOtherMembers: number) { diff --git a/lib/shared/threads/protocols/farcaster-thread-protocol.js b/lib/shared/threads/protocols/farcaster-thread-protocol.js --- a/lib/shared/threads/protocols/farcaster-thread-protocol.js +++ b/lib/shared/threads/protocols/farcaster-thread-protocol.js @@ -55,6 +55,7 @@ farcasterThreadIDFromConversationID, } from '../../id-utils.js'; import { messageNotifyTypes } from '../../messages/message-spec.js'; +import { protocolNames } from '../../protocol-names.js'; import { getContainingThreadID, getSingleOtherUser, @@ -768,6 +769,11 @@ webChatThreadListIcon: 'lock', threadAncestorLabel: () => 'Farcaster DC', threadSearchHeaderShowsGenesis: false, + protocolIcon: 'farcaster', + description: + 'Farcaster Direct Casts are the native messaging protocol in ' + + 'Farcaster. They are not end-to-end encrypted, and the Farcaster ' + + 'team can see the contents of your messages.', }, supportsEncryptedMultimedia: false, @@ -792,14 +798,12 @@ }, supportsBackgroundNotifs: false, viewerCanUpdateOwnRole: false, + + protocolName: protocolNames.FARCASTER_DC, }; function pendingThreadType(numberOfOtherMembers: number) { - invariant( - numberOfOtherMembers > 0, - 'Farcaster protocol does not support private thread type', - ); - if (numberOfOtherMembers === 1) { + if (numberOfOtherMembers <= 1) { return threadTypes.FARCASTER_PERSONAL; } else { return threadTypes.FARCASTER_GROUP; diff --git a/lib/shared/threads/protocols/keyserver-thread-protocol.js b/lib/shared/threads/protocols/keyserver-thread-protocol.js --- a/lib/shared/threads/protocols/keyserver-thread-protocol.js +++ b/lib/shared/threads/protocols/keyserver-thread-protocol.js @@ -77,6 +77,7 @@ import { generatePendingThreadColor } from '../../color-utils.js'; import { getNextLocalID } from '../../id-utils.js'; import { messageNotifyTypes } from '../../messages/message-spec.js'; +import { protocolNames } from '../../protocol-names.js'; import { getCommunity, getContainingThreadID, @@ -704,6 +705,11 @@ webChatThreadListIcon: 'server', threadAncestorLabel: (ancestorPath: React.Node) => ancestorPath, threadSearchHeaderShowsGenesis: true, + protocolIcon: 'server', + description: + "Genesis chats are a legacy chat type hosted on Ashoat's keyserver. " + + 'They are not end-to-end encrypted, and Ashoat can see the contents ' + + 'of your messages.', }, supportsEncryptedMultimedia: true, @@ -740,6 +746,7 @@ }, supportsBackgroundNotifs: true, viewerCanUpdateOwnRole: true, + protocolName: protocolNames.KEYSERVER, }); function pendingThreadType(numberOfOtherMembers: number) { diff --git a/lib/shared/threads/protocols/thread-protocols.js b/lib/shared/threads/protocols/thread-protocols.js --- a/lib/shared/threads/protocols/thread-protocols.js +++ b/lib/shared/threads/protocols/thread-protocols.js @@ -5,7 +5,7 @@ import { keyserverThreadProtocol } from './keyserver-thread-protocol.js'; import type { RawThreadInfo } from '../../../types/minimally-encoded-thread-permissions-types.js'; import { type LegacyRawThreadInfo } from '../../../types/thread-types.js'; -import { type ThreadProtocol } from '../thread-spec.js'; +import { type ThreadProtocol, type ProtocolName } from '../thread-spec.js'; import { threadSpecs } from '../thread-specs.js'; const protocols = (): $ReadOnlyArray> => [ @@ -18,6 +18,10 @@ return protocols().find(p => p.threadIDMatchesProtocol(threadID)); } +function getProtocolByName(name: ?ProtocolName): ?ThreadProtocol { + return protocols().find(p => p.protocolName === name); +} + function getDataIsBackedUpByThread( threadID: string, threadInfo: ?(LegacyRawThreadInfo | RawThreadInfo), @@ -28,4 +32,9 @@ return !!getProtocolByThreadID(threadID)?.dataIsBackedUp; } -export { protocols, getProtocolByThreadID, getDataIsBackedUpByThread }; +export { + protocols, + getProtocolByThreadID, + getDataIsBackedUpByThread, + getProtocolByName, +}; diff --git a/lib/shared/threads/thread-spec.js b/lib/shared/threads/thread-spec.js --- a/lib/shared/threads/thread-spec.js +++ b/lib/shared/threads/thread-spec.js @@ -363,6 +363,8 @@ +farcasterRefreshConversation: (conversationID: string) => Promise, }; +export type ProtocolName = 'Comm DM' | 'Farcaster DC' | 'Keyserver'; + export type ThreadProtocol< RawThreadMemberType: | MemberInfoSansPermissions @@ -476,6 +478,8 @@ +webChatThreadListIcon: 'lock' | 'server', +threadAncestorLabel: (ancestorPath: React.Node) => React.Node, +threadSearchHeaderShowsGenesis: boolean, + +protocolIcon: 'lock' | 'server' | 'farcaster', + +description: string, }, +supportsEncryptedMultimedia: boolean, +supportsSendingVideos: boolean, @@ -511,6 +515,7 @@ }, +supportsBackgroundNotifs: boolean, +viewerCanUpdateOwnRole: boolean, + +protocolName: ProtocolName, }; export type ThreadSpec< diff --git a/lib/utils/alert-utils.js b/lib/utils/alert-utils.js new file mode 100644 --- /dev/null +++ b/lib/utils/alert-utils.js @@ -0,0 +1,6 @@ +// @flow + +export const protocolInfoAlert = { + title: 'No Available Protocols', + message: 'This is the only chat type supported by the selected users.', +};