Skip to content

Instantly share code, notes, and snippets.

@infu
Created April 5, 2023 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save infu/5ba7b41da57a3c4f3d2c8658267505db to your computer and use it in GitHub Desktop.
Save infu/5ba7b41da57a3c4f3d2c8658267505db to your computer and use it in GitHub Desktop.
type AccessorId = principal;
type AccountIdentifier = blob;
type BlockIndex = nat64;
type CanisterId = principal;
type ChatId = CanisterId;
type Cycles = nat;
type EventIndex = nat32;
type FileId = nat;
type Hash = blob;
type ICP = Tokens;
type Memo = nat64;
type MessageId = nat;
type MessageIndex = nat32;
type Milliseconds = nat64;
type NnsNeuronId = nat64;
type ProposalId = nat64;
type SnsNeuronId = blob;
type TimestampMillis = nat64;
type TimestampNanos = nat64;
type Tokens = record { e8s: nat64; };
type TransactionHash = blob;
type UserId = CanisterId;
type AddedToGroupNotification =
record {
chat_id: ChatId;
group_name: text;
added_by: UserId;
added_by_name: text;
timestamp: TimestampMillis;
};
type AudioContent =
record {
caption: opt text;
mime_type: text;
blob_reference: opt BlobReference;
};
type Avatar =
record {
id: nat;
mime_type: text;
data: blob;
};
type BlobReference =
record {
canister_id: CanisterId;
blob_id: nat;
};
type CanisterUpgradeStatus =
variant {
InProgress;
NotRequired;
};
type CanisterWasm =
record {
module: vec nat8;
version: Version;
compressed: bool;
};
type ChatMetrics =
record {
text_messages: nat64;
image_messages: nat64;
video_messages: nat64;
audio_messages: nat64;
file_messages: nat64;
polls: nat64;
poll_votes: nat64;
cycles_messages: nat64;
icp_messages: nat64;
sns1_messages: nat64;
ckbtc_messages: nat64;
chat_messages: nat64;
deleted_messages: nat64;
giphy_messages: nat64;
prize_messages: nat64;
prize_winner_messages: nat64;
replies: nat64;
edits: nat64;
reactions: nat64;
proposals: nat64;
reported_messages: nat64;
last_active: TimestampMillis;
};
type CryptoContent =
record {
recipient: UserId;
transfer: CryptoTransaction;
caption: opt text;
};
type DeletedContent =
record {
deleted_by: UserId;
timestamp: TimestampMillis;
};
type DirectChatCreated =
record {
};
type DirectChatEventWrapper =
record {
index: EventIndex;
timestamp: TimestampMillis;
correlation_id: nat64;
expires_at: opt TimestampMillis;
event: ChatEvent;
};
type DirectChatSummary =
record {
them: UserId;
latest_message: MessageEventWrapper;
latest_event_index: EventIndex;
date_created: TimestampMillis;
read_by_me_up_to: opt MessageIndex;
read_by_them_up_to: opt MessageIndex;
notifications_muted: bool;
metrics: ChatMetrics;
my_metrics: ChatMetrics;
archived: bool;
events_ttl: opt Milliseconds;
expired_messages: vec MessageIndexRange;
};
type DirectChatSummaryUpdates =
record {
chat_id: ChatId;
latest_message: opt MessageEventWrapper;
latest_event_index: opt EventIndex;
read_by_me_up_to: opt MessageIndex;
read_by_them_up_to: opt MessageIndex;
notifications_muted: opt bool;
affected_events: vec EventIndex;
updated_events: vec record { nat32; nat64 };
metrics: opt ChatMetrics;
my_metrics: opt ChatMetrics;
archived: opt bool;
events_ttl: EventsTimeToLiveUpdate;
newly_expired_messages: vec MessageIndexRange;
};
type DirectMessageNotification =
record {
sender: UserId;
thread_root_message_index: opt MessageIndex;
sender_name: text;
message: MessageEventWrapper;
};
type DirectReactionAddedNotification =
record {
them: UserId;
username: text;
message: MessageEventWrapper;
reaction: text;
timestamp: TimestampMillis;
};
type FieldTooShortResult =
record {
length_provided: nat32;
min_length: nat32;
};
type FieldTooLongResult =
record {
length_provided: nat32;
max_length: nat32;
};
type FileContent =
record {
name: text;
caption: opt text;
mime_type: text;
file_size: nat32;
blob_reference: opt BlobReference;
};
type GroupChatCreated =
record {
name: text;
description: text;
created_by: UserId;
};
type ChatEvent =
variant {
Message: Message;
GroupChatCreated: GroupChatCreated;
DirectChatCreated: DirectChatCreated;
GroupNameChanged: GroupNameChanged;
GroupDescriptionChanged: GroupDescriptionChanged;
AvatarChanged: AvatarChanged;
OwnershipTransferred: OwnershipTransferred;
ParticipantsAdded: ParticipantsAdded;
ParticipantsRemoved: ParticipantsRemoved;
ParticipantJoined: ParticipantJoined;
ParticipantLeft: ParticipantLeft;
ParticipantAssumesSuperAdmin: ParticipantAssumesSuperAdmin;
ParticipantDismissedAsSuperAdmin: ParticipantDismissedAsSuperAdmin;
ParticipantRelinquishesSuperAdmin: ParticipantRelinquishesSuperAdmin;
RoleChanged: RoleChanged;
MessageEdited: UpdatedMessage;
MessageDeleted: UpdatedMessage;
MessageUndeleted: UpdatedMessage;
MessageReactionAdded: UpdatedMessage;
MessageReactionRemoved: UpdatedMessage;
UsersBlocked: UsersBlocked;
UsersUnblocked: UsersUnblocked;
MessagePinned: MessagePinned;
MessageUnpinned: MessageUnpinned;
PollVoteRegistered: UpdatedMessage;
PollVoteDeleted: UpdatedMessage;
PollEnded: PollEnded;
PermissionsChanged: PermissionsChanged;
GroupVisibilityChanged: GroupVisibilityChanged;
GroupInviteCodeChanged: GroupInviteCodeChanged;
ThreadUpdated: ThreadUpdated;
ProposalsUpdated: ProposalsUpdated;
GroupRulesChanged: GroupRulesChanged;
ChatFrozen: ChatFrozen;
ChatUnfrozen: ChatUnfrozen;
EventsTimeToLiveUpdated: EventsTimeToLiveUpdated;
};
type ChatEventWrapper =
record {
index: EventIndex;
timestamp: TimestampMillis;
correlation_id: nat64;
expires_at: opt TimestampMillis;
event: ChatEvent;
};
type GroupChatSummary =
record {
chat_id: ChatId;
last_updated: TimestampMillis;
name: text;
description: text;
subtype: opt GroupSubtype;
avatar_id: opt nat;
is_public: bool;
history_visible_to_new_joiners: bool;
min_visible_event_index: EventIndex;
min_visible_message_index: MessageIndex;
latest_message: opt MessageEventWrapper;
latest_event_index: EventIndex;
joined: TimestampMillis;
read_by_me_up_to: opt MessageIndex;
notifications_muted: bool;
participant_count: nat32;
role: Role;
mentions: vec Mention;
permissions: GroupPermissions;
metrics: ChatMetrics;
my_metrics: ChatMetrics;
latest_threads: vec ThreadSyncDetails;
archived: bool;
frozen: opt FrozenGroupInfo;
wasm_version: Version;
date_last_pinned: opt TimestampMillis;
date_read_pinned: opt TimestampMillis;
events_ttl: opt Milliseconds;
expired_messages: vec MessageIndexRange;
next_message_expiry: opt TimestampMillis;
};
type GroupCanisterGroupChatSummary =
record {
chat_id: ChatId;
last_updated: TimestampMillis;
name: text;
description: text;
subtype: opt GroupSubtype;
avatar_id: opt nat;
is_public: bool;
history_visible_to_new_joiners: bool;
min_visible_event_index: EventIndex;
min_visible_message_index: MessageIndex;
latest_message: opt MessageEventWrapper;
latest_event_index: EventIndex;
joined: TimestampMillis;
participant_count: nat32;
role: Role;
mentions: vec Mention;
permissions: GroupPermissions;
notifications_muted: bool;
metrics: ChatMetrics;
my_metrics: ChatMetrics;
latest_threads: vec GroupCanisterThreadDetails;
frozen: opt FrozenGroupInfo;
wasm_version: Version;
date_last_pinned: opt TimestampMillis;
events_ttl: opt Milliseconds;
expired_messages: vec MessageIndexRange;
next_message_expiry: opt TimestampMillis;
};
type GroupCanisterGroupChatSummaryUpdates =
record {
chat_id: ChatId;
last_updated: TimestampMillis;
name: opt text;
description: opt text;
subtype: GroupSubtypeUpdate;
avatar_id: AvatarIdUpdate;
latest_message: opt MessageEventWrapper;
latest_event_index: opt EventIndex;
participant_count: opt nat32;
role: opt Role;
mentions: vec Mention;
permissions: opt GroupPermissions;
affected_events: vec EventIndex;
updated_events: vec record { opt nat32; nat32; nat64 };
metrics: opt ChatMetrics;
my_metrics: opt ChatMetrics;
is_public: opt bool;
latest_threads: vec GroupCanisterThreadDetails;
notifications_muted: opt bool;
frozen: FrozenGroupUpdate;
wasm_version: opt Version;
date_last_pinned: opt TimestampMillis;
events_ttl: EventsTimeToLiveUpdate;
newly_expired_messages: vec MessageIndexRange;
next_message_expiry: TimestampUpdate;
};
type GroupDescriptionChanged =
record {
new_description: text;
previous_description: text;
changed_by: UserId;
};
type AvatarChanged =
record {
new_avatar: opt nat;
previous_avatar: opt nat;
changed_by: UserId;
};
type AvatarUpdate =
variant {
NoChange;
SetToNone;
SetToSome: Avatar;
};
type TextUpdate =
variant {
NoChange;
SetToNone;
SetToSome: text;
};
type AvatarIdUpdate =
variant {
NoChange;
SetToNone;
SetToSome: nat;
};
type TimestampUpdate =
variant {
NoChange;
SetToNone;
SetToSome: TimestampMillis;
};
type Mention =
record {
thread_root_message_index: opt MessageIndex;
message_id: MessageId;
message_index: MessageIndex;
event_index: EventIndex;
mentioned_by: UserId;
};
type Message =
record {
message_index: MessageIndex;
message_id: MessageId;
sender: UserId;
content: MessageContent;
replies_to: opt ReplyContext;
reactions: vec record { text; vec UserId; };
thread_summary: opt ThreadSummary;
edited: bool;
forwarded: bool;
last_updated: opt TimestampMillis;
};
type MessageEventWrapper =
record {
index: EventIndex;
timestamp: TimestampMillis;
correlation_id: nat64;
expires_at: opt TimestampMillis;
event: Message;
};
type FrozenGroupInfo =
record {
timestamp: TimestampMillis;
frozen_by: UserId;
reason: opt text;
};
type FrozenGroupUpdate =
variant {
NoChange;
SetToNone;
SetToSome: FrozenGroupInfo;
};
type GroupMessageNotification =
record {
chat_id: ChatId;
thread_root_message_index: opt MessageIndex;
group_name: text;
sender: UserId;
sender_name: text;
message: MessageEventWrapper;
mentioned: vec User;
hide: bool;
};
type GroupNameChanged =
record {
new_name: text;
previous_name: text;
changed_by: UserId;
};
type GroupReactionAddedNotification =
record {
chat_id: ChatId;
thread_root_message_index: opt MessageIndex;
group_name: text;
added_by: UserId;
added_by_name: text;
message: MessageEventWrapper;
reaction: text;
timestamp: TimestampMillis;
};
type GroupReplyContext =
record {
event_index: EventIndex;
};
type GroupSubtype =
variant {
GovernanceProposals: GovernanceProposalsSubtype;
};
type GroupSubtypeUpdate =
variant {
NoChange;
SetToNone;
SetToSome: GroupSubtype;
};
type GovernanceProposalsSubtype =
record {
is_nns: bool;
governance_canister_id: CanisterId;
};
type MessagePinned =
record {
message_index: MessageIndex;
pinned_by: UserId;
};
type MessageUnpinned =
record {
message_index: MessageIndex;
unpinned_by: UserId;
due_to_message_deleted: bool;
};
type PinnedMessageUpdate =
variant {
NoChange;
SetToNone;
SetToSome: MessageIndex;
};
type PublicGroupSummary =
record {
chat_id: ChatId;
last_updated: TimestampMillis;
name: text;
description: text;
subtype: opt GroupSubtype;
avatar_id: opt nat;
latest_message: opt MessageEventWrapper;
latest_event_index: EventIndex;
participant_count: nat32;
is_public: bool;
frozen: opt FrozenGroupInfo;
wasm_version: Version;
};
type ReplyContext =
record {
chat_id_if_other: opt ChatId;
event_index: EventIndex;
};
type GiphyImageVariant =
record {
width: nat32;
height: nat32;
url: text;
mime_type: text;
};
type GiphyContent =
record {
caption: opt text;
title: text;
desktop: GiphyImageVariant;
mobile: GiphyImageVariant;
};
type ImageContent =
record {
width: nat32;
height: nat32;
thumbnail_data: text;
caption: opt text;
mime_type: text;
blob_reference: opt BlobReference;
};
type IndexedNotification =
record {
index: nat64;
value: NotificationEnvelope;
};
type InvalidPollReason =
variant {
TooFewOptions: nat32;
TooManyOptions: nat32;
OptionTooLong: nat32;
DuplicateOptions;
EndDateInThePast;
PollsNotValidForDirectChats;
};
type MessageContentInitial =
variant {
Text: TextContent;
Image: ImageContent;
Video: VideoContent;
Audio: AudioContent;
File: FileContent;
Poll: PollContent;
Crypto: CryptoContent;
Deleted: DeletedContent;
Giphy: GiphyContent;
GovernanceProposal: ProposalContent;
Prize: PrizeContentInitial;
};
type MessageContent =
variant {
Text: TextContent;
Image: ImageContent;
Video: VideoContent;
Audio: AudioContent;
File: FileContent;
Poll: PollContent;
Crypto: CryptoContent;
Deleted: DeletedContent;
Giphy: GiphyContent;
GovernanceProposal: ProposalContent;
Prize: PrizeContent;
PrizeWinner: PrizeWinnerContent;
};
type UpdatedMessage =
record {
updated_by: UserId;
event_index: EventIndex;
message_id: MessageId;
};
type MessageMatch =
record {
chat_id: ChatId;
message_index: MessageIndex;
content: MessageContent;
sender: UserId;
score: nat32;
};
type Notification =
variant {
AddedToGroupNotification: AddedToGroupNotification;
DirectMessageNotification: DirectMessageNotification;
GroupMessageNotification: GroupMessageNotification;
DirectReactionAddedNotification: DirectReactionAddedNotification;
GroupReactionAddedNotification: GroupReactionAddedNotification;
};
type NotificationEnvelope =
record {
recipients: vec UserId;
notification: Notification;
};
type PartialUserSummary =
record {
user_id: UserId;
username: opt text;
avatar_id: opt nat;
is_bot: bool;
suspended: bool;
diamond_member: bool;
};
type Participant =
record {
user_id: UserId;
date_added: TimestampMillis;
role: Role;
};
type ParticipantJoined =
record {
user_id: UserId;
};
type ParticipantLeft =
record {
user_id: UserId;
};
type ParticipantAssumesSuperAdmin =
record {
user_id: UserId;
};
type ParticipantRelinquishesSuperAdmin =
record {
user_id: UserId;
};
type ParticipantDismissedAsSuperAdmin =
record {
user_id: UserId;
};
type ParticipantsAdded =
record {
user_ids: vec UserId;
added_by: UserId;
unblocked: vec UserId;
};
type PermissionsChanged =
record {
old_permissions: GroupPermissions;
new_permissions: GroupPermissions;
changed_by: UserId;
};
type GroupVisibilityChanged =
record {
now_public: bool;
changed_by: UserId;
};
type GroupInviteCodeChanged =
record {
change: GroupInviteCodeChange;
changed_by: UserId;
};
type GroupInviteCodeChange =
variant {
Enabled;
Disabled;
Reset;
};
type PollConfig =
record {
text: opt text;
options: vec text;
end_date: opt TimestampMillis;
anonymous: bool;
show_votes_before_end_date: bool;
allow_multiple_votes_per_user: bool;
};
type PollContent =
record {
config: PollConfig;
votes: PollVotes;
ended: bool;
};
type PollEnded =
record {
event_index: EventIndex;
message_index: MessageIndex;
};
type PollVotes =
record {
total: TotalPollVotes;
user: vec nat32;
};
type RoleChanged =
record {
user_ids: vec UserId;
changed_by: UserId;
old_role: Role;
new_role: Role;
};
type OwnershipTransferred =
record {
old_owner: UserId;
new_owner: UserId;
};
type ParticipantsRemoved =
record {
user_ids: vec UserId;
removed_by: UserId;
};
type ProposalContent =
record {
governance_canister_id: CanisterId;
proposal: Proposal;
my_vote: opt bool;
};
type Proposal =
variant {
NNS: NnsProposal;
SNS: SnsProposal;
};
type NnsProposal =
record {
id: ProposalId;
topic: int32;
proposer: NnsNeuronId;
created: TimestampMillis;
title: text;
summary: text;
url: text;
status: ProposalDecisionStatus;
reward_status: ProposalRewardStatus;
tally: Tally;
deadline: TimestampMillis;
last_updated: TimestampMillis;
};
type SnsProposal =
record {
id: ProposalId;
action: nat64;
proposer: SnsNeuronId;
created: TimestampMillis;
title: text;
summary: text;
url: text;
status: ProposalDecisionStatus;
reward_status: ProposalRewardStatus;
tally: Tally;
deadline: TimestampMillis;
payload_text_rendering: opt text;
last_updated: TimestampMillis;
};
type ProposalDecisionStatus =
variant {
Unspecified;
Open;
Rejected;
Adopted;
Executed;
Failed;
};
type ProposalRewardStatus =
variant {
Unspecified;
AcceptVotes;
ReadyToSettle;
Settled;
};
type Tally =
record {
yes: nat64;
no: nat64;
total: nat64;
timestamp: TimestampMillis;
};
type TotalPollVotes =
variant {
Visible: vec record { nat32; vec UserId };
Anonymous: vec record { nat32; nat32 };
Hidden: nat32;
};
type UsersBlocked =
record {
user_ids: vec UserId;
blocked_by: UserId;
};
type UsersUnblocked =
record {
user_ids: vec UserId;
unblocked_by: UserId;
};
type VoteOperation =
variant {
RegisterVote;
DeleteVote;
};
type RegistrationFee =
variant {
ICP: ICPRegistrationFee;
Cycles: CyclesRegistrationFee;
};
type ICPRegistrationFee =
record {
amount: ICP;
recipient: AccountIdentifier;
valid_until: TimestampMillis;
};
type CyclesRegistrationFee =
record {
amount: Cycles;
recipient: principal;
valid_until: TimestampMillis;
};
type Role =
variant {
Owner;
Admin;
Participant;
};
type FallbackRole =
variant {
Admin;
Participant;
};
type Subscription =
record {
value: SubscriptionInfo;
last_active: TimestampMillis;
};
type SubscriptionInfo =
record {
endpoint: text;
keys: SubscriptionKeys;
};
type SubscriptionKeys =
record {
p256dh: text;
auth: text;
};
type TextContent =
record {
text: text;
};
type UserSummary =
record {
user_id: UserId;
username: text;
avatar_id: opt nat;
is_bot: bool;
suspended: bool;
seconds_since_last_online: nat32;
diamond_member: bool;
};
type Version =
record {
major: nat32;
minor: nat32;
patch: nat32;
};
type Cryptocurrency =
variant {
InternetComputer;
SNS1;
CKBTC;
CHAT;
};
type CryptoTransaction =
variant {
Pending: PendingCryptoTransaction;
Completed: CompletedCryptoTransaction;
Failed: FailedCryptoTransaction;
};
type PendingCryptoTransaction =
variant {
NNS: NnsPendingCryptoTransaction;
SNS: SnsPendingCryptoTransaction;
};
type CompletedCryptoTransaction =
variant {
NNS: NnsCompletedCryptoTransaction;
SNS: SnsCompletedCryptoTransaction;
};
type FailedCryptoTransaction =
variant {
NNS: NnsFailedCryptoTransaction;
SNS: SnsFailedCryptoTransaction;
};
type NnsPendingCryptoTransaction =
record {
token: Cryptocurrency;
amount: Tokens;
to: NnsUserOrAccount;
fee: opt Tokens;
memo: opt Memo;
};
type NnsCompletedCryptoTransaction =
record {
token: Cryptocurrency;
amount: Tokens;
fee: Tokens;
from: NnsCryptoAccount;
to: NnsCryptoAccount;
memo: Memo;
created: TimestampNanos;
transaction_hash: TransactionHash;
block_index: BlockIndex;
};
type NnsFailedCryptoTransaction =
record {
token: Cryptocurrency;
amount: Tokens;
fee: Tokens;
from: NnsCryptoAccount;
to: NnsCryptoAccount;
memo: Memo;
created: TimestampNanos;
transaction_hash: TransactionHash;
error_message: text;
};
type NnsUserOrAccount =
variant {
User: UserId;
Account: AccountIdentifier;
};
type NnsCryptoAccount =
variant {
Mint;
Account: AccountIdentifier;
};
type SnsPendingCryptoTransaction =
record {
token: Cryptocurrency;
amount: Tokens;
to: Icrc1Account;
fee: Tokens;
memo: opt Memo;
};
type SnsCompletedCryptoTransaction =
record {
token: Cryptocurrency;
amount: Tokens;
fee: Tokens;
from: SnsAccount;
to: SnsAccount;
memo: opt Memo;
created: TimestampNanos;
transaction_hash: TransactionHash;
block_index: BlockIndex;
};
type SnsFailedCryptoTransaction =
record {
token: Cryptocurrency;
amount: Tokens;
fee: Tokens;
from: SnsAccount;
to: SnsAccount;
memo: opt Memo;
created: TimestampNanos;
transaction_hash: TransactionHash;
error_message: text;
};
type SnsAccount =
variant {
Mint;
Account: Icrc1Account;
};
type Icrc1Account =
record {
owner: principal;
subaccount: opt blob;
};
type VideoContent =
record {
width: nat32;
height: nat32;
thumbnail_data: text;
caption: opt text;
mime_type: text;
image_blob_reference: opt BlobReference;
video_blob_reference: opt BlobReference;
};
type User =
record {
user_id: UserId;
username: text;
};
type GroupPermissions =
record {
change_permissions: PermissionRole;
change_roles: PermissionRole;
add_members: PermissionRole;
remove_members: PermissionRole;
block_users: PermissionRole;
delete_messages: PermissionRole;
update_group: PermissionRole;
pin_messages: PermissionRole;
invite_users: PermissionRole;
create_polls: PermissionRole;
send_messages: PermissionRole;
react_to_messages: PermissionRole;
reply_in_thread: PermissionRole;
};
type PermissionRole =
variant {
Owner;
Admins;
Members;
};
type ThreadSummary =
record {
participant_ids: vec UserId;
reply_count: nat32;
latest_event_index: EventIndex;
latest_event_timestamp: TimestampMillis;
};
type ThreadUpdated =
record {
event_index: EventIndex;
message_index: MessageIndex;
latest_thread_message_index_if_updated: opt MessageIndex;
};
type ThreadSyncDetails =
record {
root_message_index: MessageIndex;
latest_event: opt EventIndex;
latest_message: opt MessageIndex;
read_up_to: opt MessageIndex;
last_updated: TimestampMillis;
};
type GroupCanisterThreadDetails =
record {
root_message_index: MessageIndex;
latest_event: EventIndex;
latest_message: MessageIndex;
last_updated: TimestampMillis;
};
type ProposalsUpdated =
record {
proposals: vec ProposalUpdated;
};
type ProposalUpdated =
record {
event_index: EventIndex;
message_index: MessageIndex;
};
type GroupRules =
record {
text: text;
enabled: bool;
};
type GroupRulesChanged =
record {
enabled: bool;
prev_enabled: bool;
changed_by: UserId;
};
type ChatFrozen =
record {
frozen_by: UserId;
reason: opt text;
};
type ChatUnfrozen =
record {
unfrozen_by: UserId;
};
type EventsTimeToLiveUpdated =
record {
updated_by: UserId;
new_ttl: opt Milliseconds;
};
type EventsTimeToLiveUpdate =
variant {
NoChange;
SetToNone;
SetToSome: Milliseconds;
};
type PushEventResult =
record {
index: EventIndex;
timestamp: TimestampMillis;
expires_at: opt TimestampMillis;
};
type MessageIndexRange =
record {
start: MessageIndex;
end: MessageIndex;
};
type PrizeContentInitial =
record {
prizes: vec Tokens;
transfer: CryptoTransaction;
end_date: TimestampMillis;
caption: opt text;
};
type PrizeContent =
record {
prizes_remaining: nat32;
prizes_pending: nat32;
winners: vec UserId;
token: Cryptocurrency;
end_date: TimestampMillis;
caption: opt text;
};
type PrizeWinnerContent =
record {
winner: UserId;
transaction: CompletedCryptoTransaction;
prize_message: MessageIndex;
};
type DiamondMembershipDetails =
record {
expires_at: TimestampMillis;
recurring: opt DiamondMembershipPlanDuration;
};
type DiamondMembershipPlanDuration =
variant {
OneMonth;
ThreeMonths;
OneYear;
};
type SendMessageArgs =
record {
message_id: MessageId;
thread_root_message_index: opt MessageIndex;
content: MessageContent;
sender_name: text;
replies_to: opt GroupReplyContext;
mentioned: vec User;
forwarding: bool;
correlation_id: nat64;
};
type SendMessageResponse =
variant {
Success: record {
message_index: MessageIndex;
event_index: EventIndex;
timestamp: TimestampMillis;
expires_at: opt TimestampMillis;
};
MessageEmpty;
TextTooLong: nat32;
InvalidPoll: InvalidPollReason;
NotAuthorized;
CallerNotInGroup;
InvalidRequest: text;
ThreadMessageNotFound;
UserSuspended;
ChatFrozen;
};
type SendMessageV2Args =
record {
message_id: MessageId;
thread_root_message_index: opt MessageIndex;
content: MessageContentInitial;
sender_name: text;
replies_to: opt GroupReplyContext;
mentioned: vec User;
forwarding: bool;
correlation_id: nat64;
};
type EditMessageArgs =
record {
thread_root_message_index: opt MessageIndex;
message_id: MessageId;
content: MessageContent;
correlation_id: nat64;
};
type EditMessageResponse =
variant {
Success;
MessageNotFound;
CallerNotInGroup;
UserSuspended;
ChatFrozen;
};
type DeleteMessagesArgs =
record {
thread_root_message_index: opt MessageIndex;
message_ids: vec MessageId;
correlation_id: nat64;
};
type DeleteMessagesResponse =
variant {
Success;
CallerNotInGroup;
MessageNotFound;
UserSuspended;
ChatFrozen;
};
type UndeleteMessagesArgs =
record {
thread_root_message_index: opt MessageIndex;
message_ids: vec MessageId;
correlation_id: nat64;
};
type UndeleteMessagesResponse =
variant {
Success: record {
messages: vec Message;
};
CallerNotInGroup;
MessageNotFound;
UserSuspended;
ChatFrozen;
};
type RegisterPollVoteArgs =
record {
thread_root_message_index: opt MessageIndex;
message_index: MessageIndex;
poll_option: nat32;
operation: VoteOperation;
correlation_id: nat64;
};
type RegisterPollVoteResponse =
variant {
Success: PollVotes;
PollNotFound;
PollEnded;
OptionIndexOutOfRange;
CallerNotInGroup;
UserSuspended;
ChatFrozen;
};
type AddReactionArgs =
record {
thread_root_message_index: opt MessageIndex;
message_id: MessageId;
reaction: text;
username: text;
correlation_id: nat64;
};
type AddReactionResponse =
variant {
Success;
SuccessV2: PushEventResult;
NoChange;
InvalidReaction;
MessageNotFound;
CallerNotInGroup;
NotAuthorized;
UserSuspended;
ChatFrozen;
};
type RemoveReactionArgs =
record {
thread_root_message_index: opt MessageIndex;
message_id: MessageId;
reaction: text;
correlation_id: nat64;
};
type RemoveReactionResponse =
variant {
Success;
SuccessV2: PushEventResult;
NoChange;
MessageNotFound;
CallerNotInGroup;
NotAuthorized;
UserSuspended;
ChatFrozen;
};
type BlockUserArgs =
record {
user_id: UserId;
correlation_id: nat64;
};
type BlockUserResponse =
variant {
Success;
CallerNotInGroup;
CannotBlockSelf;
CannotBlockUser;
GroupNotPublic;
InternalError: text;
NotAuthorized;
UserNotInGroup;
UserSuspended;
ChatFrozen;
};
type UnblockUserArgs =
record {
user_id: UserId;
correlation_id: nat64;
};
type UnblockUserResponse =
variant {
Success;
CallerNotInGroup;
CannotUnblockSelf;
GroupNotPublic;
NotAuthorized;
UserSuspended;
ChatFrozen;
};
type AddParticipantsArgs =
record {
user_ids: vec UserId;
added_by_name: text;
allow_blocked_users: bool;
correlation_id: nat64;
};
type AddParticipantsResponse =
variant {
Success;
PartialSuccess: AddParticipantsPartialSuccessResult;
Failed: AddParticipantsFailedResult;
CallerNotInGroup;
ParticipantLimitReached: nat32;
NotAuthorized;
UserSuspended;
ChatFrozen;
};
type AddParticipantsPartialSuccessResult =
record {
users_added: vec UserId;
users_already_in_group: vec UserId;
users_blocked_from_group: vec UserId;
users_who_blocked_request: vec UserId;
users_not_authorized_to_add: vec UserId;
users_suspended: vec UserId;
errors: vec UserId;
};
type AddParticipantsFailedResult =
record {
users_already_in_group: vec UserId;
users_blocked_from_group: vec UserId;
users_who_blocked_request: vec UserId;
users_suspended: vec UserId;
errors: vec UserId;
};
type RemoveParticipantArgs =
record {
user_id: UserId;
correlation_id: nat64;
};
type RemoveParticipantResponse =
variant {
Success;
CallerNotInGroup;
CannotRemoveSelf;
CannotRemoveUser;
InternalError: text;
NotAuthorized;
UserNotInGroup;
UserSuspended;
ChatFrozen;
};
type ChangeRoleArgs =
record {
user_id: UserId;
new_role: Role;
correlation_id: nat64;
};
type ChangeRoleResponse =
variant {
Success;
CallerNotInGroup;
NotAuthorized;
UserNotInGroup;
Invalid;
UserSuspended;
ChatFrozen;
InternalError: text;
};
type InviteCodeArgs =
record {
};
type InviteCodeResponse =
variant {
Success: record {
code: opt nat64;
};
NotAuthorized;
};
type EnableInviteCodeArgs =
record {
correlation_id: nat64;
};
type EnableInviteCodeResponse =
variant {
Success: record {
code: nat64;
};
NotAuthorized;
UserSuspended;
ChatFrozen;
};
type DisableInviteCodeArgs =
record {
correlation_id: nat64;
};
type DisableInviteCodeResponse =
variant {
Success;
NotAuthorized;
UserSuspended;
ChatFrozen;
};
type ResetInviteCodeArgs =
record {
correlation_id: nat64;
};
type ResetInviteCodeResponse =
variant {
Success: record {
code: nat64;
};
NotAuthorized;
UserSuspended;
ChatFrozen;
};
type UpdateGroupV2Args =
record {
name: opt text;
description: opt text;
rules: opt GroupRules;
avatar: AvatarUpdate;
permissions: opt OptionalGroupPermissions;
events_ttl: EventsTimeToLiveUpdate;
correlation_id: nat64;
};
type UpdateGroupV2Response =
variant {
Success;
NotAuthorized;
CallerNotInGroup;
NameTooShort: FieldTooShortResult;
NameTooLong: FieldTooLongResult;
NameReserved;
DescriptionTooLong: FieldTooLongResult;
AvatarTooBig: FieldTooLongResult;
NameTaken;
InternalError;
RulesTooLong: FieldTooLongResult;
RulesTooShort: FieldTooShortResult;
UserSuspended;
ChatFrozen;
};
type OptionalGroupPermissions =
record {
change_permissions: opt PermissionRole;
change_roles: opt PermissionRole;
add_members: opt PermissionRole;
remove_members: opt PermissionRole;
block_users: opt PermissionRole;
delete_messages: opt PermissionRole;
update_group: opt PermissionRole;
pin_messages: opt PermissionRole;
invite_users: opt PermissionRole;
create_polls: opt PermissionRole;
send_messages: opt PermissionRole;
react_to_messages: opt PermissionRole;
reply_in_thread: opt PermissionRole;
};
type PinMessageArgs =
record {
message_index: MessageIndex;
correlation_id: nat64;
};
type PinMessageV2Response =
variant {
Success: PushEventResult;
NoChange;
MessageIndexOutOfRange;
NotAuthorized;
CallerNotInGroup;
MessageNotFound;
UserSuspended;
ChatFrozen;
};
type UnpinMessageArgs =
record {
message_index: MessageIndex;
correlation_id: nat64;
};
type UnpinMessageResponse =
variant {
Success: EventIndex;
SuccessV2: PushEventResult;
NoChange;
NotAuthorized;
CallerNotInGroup;
MessageNotFound;
UserSuspended;
ChatFrozen;
};
type RegisterProposalVoteArgs =
record {
message_index: MessageIndex;
adopt: bool;
};
type RegisterProposalVoteResponse =
variant {
Success;
AlreadyVoted: bool;
CallerNotInGroup;
NoEligibleNeurons;
ProposalMessageNotFound;
ProposalNotFound;
ProposalNotAcceptingVotes;
UserSuspended;
ChatFrozen;
InternalError: text;
};
type ClaimPrizeArgs =
record {
message_id: MessageId;
correlation_id: nat64;
};
type ClaimPrizeResponse =
variant {
Success;
CallerNotInGroup;
UserSuspended;
ChatFrozen;
MessageNotFound;
AlreadyClaimed;
PrizeFullyClaimed;
PrizeEnded;
TransferFailed: record { text; FailedCryptoTransaction; };
FailedAfterTransfer: record { text; CompletedCryptoTransaction; };
};
type MakePrivateArgs =
record {
correlation_id: nat64;
};
type MakePrivateResponse =
variant {
Success;
NotAuthorized;
AlreadyPrivate;
UserSuspended;
ChatFrozen;
InternalError;
};
type SummaryArgs =
record {
};
type SummaryResponse =
variant {
Success: record {
summary: GroupCanisterGroupChatSummary;
};
CallerNotInGroup;
};
type SummaryUpdatesArgs =
record {
updates_since: TimestampMillis;
};
type SummaryUpdatesResponse =
variant {
Success: record {
updates: GroupCanisterGroupChatSummaryUpdates;
};
SuccessNoUpdates;
CallerNotInGroup;
};
type SelectedInitialArgs =
record {
};
type SelectedInitialSuccess =
record {
latest_event_index: EventIndex;
participants: vec Participant;
blocked_users: vec UserId;
pinned_messages: vec MessageIndex;
rules: GroupRules;
};
type SelectedInitialResponse =
variant {
Success: SelectedInitialSuccess;
CallerNotInGroup;
};
type SelectedUpdatesArgs =
record {
updates_since: EventIndex
};
type SelectedUpdatesSuccess =
record {
latest_event_index: EventIndex;
participants_added_or_updated: vec Participant;
participants_removed: vec UserId;
blocked_users_added: vec UserId;
blocked_users_removed: vec UserId;
pinned_messages_added: vec MessageIndex;
pinned_messages_removed: vec MessageIndex;
rules: opt GroupRules;
};
type SelectedUpdatesResponse =
variant {
Success: SelectedUpdatesSuccess;
SuccessNoUpdates: EventIndex;
CallerNotInGroup;
};
type EventsArgs =
record {
thread_root_message_index: opt MessageIndex;
start_index: EventIndex;
ascending: bool;
max_messages: nat32;
max_events: nat32;
invite_code: opt nat64;
latest_client_event_index: opt EventIndex;
};
type EventsByIndexArgs =
record {
thread_root_message_index: opt MessageIndex;
events: vec EventIndex;
invite_code: opt nat64;
latest_client_event_index: opt EventIndex;
};
type EventsWindowArgs =
record {
thread_root_message_index: opt MessageIndex;
mid_point: MessageIndex;
max_messages: nat32;
max_events: nat32;
invite_code: opt nat64;
latest_client_event_index: opt EventIndex;
};
type EventsSuccessResult =
record {
events: vec ChatEventWrapper;
latest_event_index: nat32;
timestamp: TimestampMillis;
};
type EventsResponse =
variant {
Success: EventsSuccessResult;
CallerNotInGroup;
ThreadMessageNotFound;
ReplicaNotUpToDate: EventIndex;
};
type LocalUserIndexArgs =
record {
};
type LocalUserIndexResponse =
variant {
Success: CanisterId;
};
type MessagesByMessageIndexArgs =
record {
thread_root_message_index: opt MessageIndex;
messages: vec MessageIndex;
invite_code: opt nat64;
latest_client_event_index: opt EventIndex;
};
type MessagesByMessageIndexResponse =
variant {
Success: record {
messages: vec MessageEventWrapper;
latest_event_index: EventIndex;
};
CallerNotInGroup;
ThreadMessageNotFound;
ReplicaNotUpToDate: EventIndex;
};
type ThreadPreviewsArgs =
record {
threads: vec MessageIndex;
latest_client_thread_update: opt TimestampMillis;
};
type ThreadPreviewsResponse =
variant {
Success: record {
threads: vec ThreadPreview;
timestamp: TimestampMillis;
};
CallerNotInGroup;
ReplicaNotUpToDate: TimestampMillis;
};
type ThreadPreview =
record {
root_message: MessageEventWrapper;
latest_replies: vec MessageEventWrapper;
total_replies: nat32;
};
type DeletedMessageArgs =
record {
thread_root_message_index: opt MessageIndex;
message_id: MessageId;
};
type DeletedMessageResponse =
variant {
Success: record {
content: MessageContent;
};
CallerNotInGroup;
NotAuthorized;
MessageNotFound;
MessageNotDeleted;
MessageHardDeleted;
};
type SearchMessagesArgs =
record {
search_term: text;
max_results: nat8;
users: opt vec UserId;
};
type SearchMessagesResponse =
variant {
Success: SearchMessagesSuccessResult;
TermTooShort: nat8;
TermTooLong: nat8;
TooManyUsers: nat8;
InvalidTerm;
CallerNotInGroup;
};
type SearchMessagesSuccessResult =
record {
matches: vec MessageMatch;
};
type PublicSummaryArgs =
record {
invite_code: opt nat64;
};
type PublicSummaryResponse =
variant {
Success: PublicSummarySuccess;
NotAuthorized;
};
type PublicSummarySuccess =
record {
summary: PublicGroupSummary;
};
type RulesArgs =
record {
invite_code: opt nat64;
};
type RulesResponse =
variant {
Success: RulesSuccess;
NotAuthorized;
};
type RulesSuccess =
record {
rules: opt text;
};
service: {
// Owner only
make_private: (MakePrivateArgs) -> (MakePrivateResponse);
// Admin only
block_user: (BlockUserArgs) -> (BlockUserResponse); // public only
unblock_user: (UnblockUserArgs) -> (UnblockUserResponse); // public only
remove_participant: (RemoveParticipantArgs) -> (RemoveParticipantResponse);
update_group_v2: (UpdateGroupV2Args) -> (UpdateGroupV2Response);
pin_message_v2: (PinMessageArgs) -> (PinMessageV2Response);
unpin_message: (UnpinMessageArgs) -> (UnpinMessageResponse);
change_role: (ChangeRoleArgs) -> (ChangeRoleResponse);
invite_code: (InviteCodeArgs) -> (InviteCodeResponse) query;
enable_invite_code: (EnableInviteCodeArgs) -> (EnableInviteCodeResponse);
disable_invite_code: (DisableInviteCodeArgs) -> (DisableInviteCodeResponse);
reset_invite_code: (ResetInviteCodeArgs) -> (ResetInviteCodeResponse);
// Can be called by admins or regular users of public groups
add_participants: (AddParticipantsArgs) -> (AddParticipantsResponse);
// Regular users
send_message: (SendMessageArgs) -> (SendMessageResponse);
send_message_v2: (SendMessageV2Args) -> (SendMessageResponse);
edit_message: (EditMessageArgs) -> (EditMessageResponse);
delete_messages: (DeleteMessagesArgs) -> (DeleteMessagesResponse);
undelete_messages: (UndeleteMessagesArgs) -> (UndeleteMessagesResponse);
register_poll_vote: (RegisterPollVoteArgs) -> (RegisterPollVoteResponse);
add_reaction: (AddReactionArgs) -> (AddReactionResponse);
remove_reaction: (RemoveReactionArgs) -> (RemoveReactionResponse);
register_proposal_vote: (RegisterProposalVoteArgs) -> (RegisterProposalVoteResponse);
claim_prize: (ClaimPrizeArgs) -> (ClaimPrizeResponse);
summary: (SummaryArgs) -> (SummaryResponse) query;
summary_updates: (SummaryUpdatesArgs) -> (SummaryUpdatesResponse) query;
selected_initial: (SelectedInitialArgs) -> (SelectedInitialResponse) query;
selected_updates: (SelectedUpdatesArgs) -> (SelectedUpdatesResponse) query;
events: (EventsArgs) -> (EventsResponse) query;
events_by_index: (EventsByIndexArgs) -> (EventsResponse) query;
events_window: (EventsWindowArgs) -> (EventsResponse) query;
local_user_index: (LocalUserIndexArgs) -> (LocalUserIndexResponse) query;
messages_by_message_index: (MessagesByMessageIndexArgs) -> (MessagesByMessageIndexResponse) query;
thread_previews: (ThreadPreviewsArgs) -> (ThreadPreviewsResponse) query;
deleted_message: (DeletedMessageArgs) -> (DeletedMessageResponse) query;
search_messages: (SearchMessagesArgs) -> (SearchMessagesResponse) query; // Use Tantivy
public_summary: (PublicSummaryArgs) -> (PublicSummaryResponse) query;
rules: (RulesArgs) -> (RulesResponse) query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment