-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
4,155 additions
and
806 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
packages/status-js/proto/communities/v1/chat_identity.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
syntax = "proto3"; | ||
|
||
package communities.v1; | ||
|
||
import "communities/v1/enums.proto"; | ||
|
||
// Cha// ChatIdentity represents the user defined identity associated with their public chat key | ||
message ChatIdentity { | ||
// Lamport timestamp of the message | ||
uint64 clock = 1; | ||
|
||
// ens_name is the valid ENS name associated with the chat key | ||
string ens_name = 2; | ||
|
||
// images is a string indexed mapping of images associated with an identity | ||
map<string, IdentityImage> images = 3; | ||
|
||
// display name is the user set identity | ||
string display_name = 4; | ||
|
||
// description is the user set description | ||
string description = 5; | ||
|
||
string color = 6; | ||
|
||
string emoji = 7; | ||
|
||
repeated SocialLink social_links = 8; | ||
|
||
// first known message timestamp in seconds (valid only for community chats for now) | ||
// 0 - unknown | ||
// 1 - no messages | ||
uint32 first_message_timestamp = 9; | ||
} | ||
|
||
// ProfileImage represents data associated with a user's profile image | ||
message IdentityImage { | ||
|
||
// payload is a context based payload for the profile image data, | ||
// context is determined by the `source_type` | ||
bytes payload = 1; | ||
|
||
// source_type signals the image payload source | ||
SourceType source_type = 2; | ||
|
||
// image_type signals the image type and method of parsing the payload | ||
ImageType image_type = 3; | ||
|
||
// encryption_keys is a list of encrypted keys that can be used to decrypted an encrypted payload | ||
repeated bytes encryption_keys = 4; | ||
|
||
// encrypted signals the encryption state of the payload, default is false. | ||
bool encrypted = 5; | ||
|
||
// SourceType are the predefined types of image source allowed | ||
enum SourceType { | ||
UNKNOWN_SOURCE_TYPE = 0; | ||
|
||
// RAW_PAYLOAD image byte data | ||
RAW_PAYLOAD = 1; | ||
|
||
// ENS_AVATAR uses the ENS record's resolver get-text-data.avatar data | ||
// The `payload` field will be ignored if ENS_AVATAR is selected | ||
// The application will read and parse the ENS avatar data as image payload data, URLs will be ignored | ||
// The parent `ChatMessageIdentity` must have a valid `ens_name` set | ||
ENS_AVATAR = 2; | ||
} | ||
} | ||
|
||
// SocialLinks represents social link assosiated with given chat identity (personal/community) | ||
message SocialLink { | ||
string text = 1; | ||
string url = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
syntax = "proto3"; | ||
|
||
package communities.v1; | ||
|
||
enum MessageType { | ||
UNKNOWN_MESSAGE_TYPE = 0; | ||
ONE_TO_ONE = 1; | ||
PUBLIC_GROUP = 2; | ||
PRIVATE_GROUP = 3; | ||
// Only local | ||
SYSTEM_MESSAGE_PRIVATE_GROUP = 4; | ||
COMMUNITY_CHAT = 5; | ||
// Only local | ||
SYSTEM_MESSAGE_GAP = 6; | ||
} | ||
|
||
enum ImageType { | ||
UNKNOWN_IMAGE_TYPE = 0; | ||
|
||
// Raster image files is payload data that can be read as a raster image | ||
PNG = 1; | ||
JPEG = 2; | ||
WEBP = 3; | ||
GIF = 4; | ||
} |
105 changes: 105 additions & 0 deletions
105
packages/status-js/proto/communities/v1/push_notifications.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
syntax = "proto3"; | ||
|
||
package communities.v1; | ||
|
||
import "communities/v1/chat_identity.proto"; | ||
|
||
message PushNotificationRegistration { | ||
enum TokenType { | ||
UNKNOWN_TOKEN_TYPE = 0; | ||
APN_TOKEN = 1; | ||
FIREBASE_TOKEN = 2; | ||
} | ||
TokenType token_type = 1; | ||
string device_token = 2; | ||
string installation_id = 3; | ||
string access_token = 4; | ||
bool enabled = 5; | ||
uint64 version = 6; | ||
repeated bytes allowed_key_list = 7; | ||
repeated bytes blocked_chat_list = 8; | ||
bool unregister = 9; | ||
bytes grant = 10; | ||
bool allow_from_contacts_only = 11; | ||
string apn_topic = 12; | ||
bool block_mentions = 13; | ||
repeated bytes allowed_mentions_chat_list = 14; | ||
} | ||
|
||
message PushNotificationRegistrationResponse { | ||
bool success = 1; | ||
ErrorType error = 2; | ||
bytes request_id = 3; | ||
|
||
enum ErrorType { | ||
UNKNOWN_ERROR_TYPE = 0; | ||
MALFORMED_MESSAGE = 1; | ||
VERSION_MISMATCH = 2; | ||
UNSUPPORTED_TOKEN_TYPE = 3; | ||
INTERNAL_ERROR = 4; | ||
} | ||
} | ||
|
||
message ContactCodeAdvertisement { | ||
repeated PushNotificationQueryInfo push_notification_info = 1; | ||
ChatIdentity chat_identity = 2; | ||
} | ||
|
||
message PushNotificationQuery { | ||
repeated bytes public_keys = 1; | ||
} | ||
|
||
message PushNotificationQueryInfo { | ||
string access_token = 1; | ||
string installation_id = 2; | ||
bytes public_key = 3; | ||
repeated bytes allowed_key_list = 4; | ||
bytes grant = 5; | ||
uint64 version = 6; | ||
bytes server_public_key = 7; | ||
} | ||
|
||
message PushNotificationQueryResponse { | ||
repeated PushNotificationQueryInfo info = 1; | ||
bytes message_id = 2; | ||
bool success = 3; | ||
} | ||
|
||
message PushNotification { | ||
string access_token = 1; | ||
bytes chat_id = 2; | ||
bytes public_key = 3; | ||
string installation_id = 4; | ||
bytes message = 5; | ||
PushNotificationType type = 6; | ||
enum PushNotificationType { | ||
UNKNOWN_PUSH_NOTIFICATION_TYPE = 0; | ||
MESSAGE = 1; | ||
MENTION = 2; | ||
REQUEST_TO_JOIN_COMMUNITY = 3; | ||
} | ||
bytes author = 7; | ||
} | ||
|
||
message PushNotificationRequest { | ||
repeated PushNotification requests = 1; | ||
bytes message_id = 2; | ||
} | ||
|
||
message PushNotificationReport { | ||
bool success = 1; | ||
ErrorType error = 2; | ||
enum ErrorType { | ||
UNKNOWN_ERROR_TYPE = 0; | ||
WRONG_TOKEN = 1; | ||
INTERNAL_ERROR = 2; | ||
NOT_REGISTERED = 3; | ||
} | ||
bytes public_key = 3; | ||
string installation_id = 4; | ||
} | ||
|
||
message PushNotificationResponse { | ||
bytes message_id = 1; | ||
repeated PushNotificationReport reports = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
syntax = "proto3"; | ||
|
||
package status.v1; | ||
|
||
message SignedPreKey { | ||
bytes signed_pre_key = 1; | ||
uint32 version = 2; | ||
|
49 changes: 49 additions & 0 deletions
49
packages/status-js/src/preview-client/map-community-chat-preview.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { mapCommunityPreview } from './map-community-preview' | ||
|
||
import type { | ||
CommunityChat, | ||
CommunityDescription, | ||
} from '../proto/communities/v1/communities' | ||
import type { CommunityPreview } from './map-community-preview' | ||
|
||
export type CommunityChatPreview = { | ||
emoji?: string | ||
displayName: string | ||
description: string | ||
appUrl: string | ||
color: string | ||
community: CommunityPreview | ||
} | ||
|
||
export function mapCommunityChatPreview( | ||
communityChat: CommunityChat, | ||
communityDescription: CommunityDescription, | ||
communityPublicKey: string, | ||
communityChatUuid: string | ||
): CommunityChatPreview | undefined { | ||
const community = mapCommunityPreview( | ||
communityDescription, | ||
communityPublicKey | ||
) | ||
|
||
if (!community) { | ||
return | ||
} | ||
|
||
const { identity } = communityChat | ||
|
||
if (!identity) { | ||
return | ||
} | ||
|
||
const communityChatPreview: CommunityChatPreview = { | ||
emoji: identity.emoji, | ||
displayName: identity.displayName, | ||
description: identity.description, | ||
color: identity.color, | ||
appUrl: `status-im://cc/${communityPublicKey}/${communityChatUuid}`, | ||
community, | ||
} | ||
|
||
return communityChatPreview | ||
} |
Oops, something went wrong.