Skip to content

the great protocol refactor #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 68 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
809b534
feat(chat): add invite created / deleted / used events
90-008 Feb 3, 2022
b7d1cd8
docs: document IDs, document more stuff
90-008 Feb 6, 2022
6e7dbf2
docs(ids): document emote pack and user ids
90-008 Feb 6, 2022
ebc06c1
docs(batch): document it better
90-008 Feb 6, 2022
43b1d79
fix(chat): revert breaking change
90-008 Feb 6, 2022
caf363e
fix: override avatars can be hmc, file id or external image url
90-008 Feb 6, 2022
df5abd2
fix(chat): add guild_ids to owner added / removed events
90-008 Feb 6, 2022
9dd16e2
docs(chat): fix typo
90-008 Feb 7, 2022
078f155
docs(emote): document that addemotetopack can take a file id
90-008 Feb 9, 2022
187ea91
refactor(chat): move text content to root of content, improve attachm…
90-008 Feb 11, 2022
166dab0
refactor(chat): use emote in emoji format
90-008 Feb 11, 2022
8e4da89
feat(chat): seperate content type for sending messages
90-008 Feb 11, 2022
bc4eb21
refactor: remove batch, replace most get endpoints with 'batched' var…
90-008 Feb 11, 2022
35109fc
feat: add image resolution to embeds, fix ids
90-008 Feb 11, 2022
cd89e8e
feat(mediaproxy): add image resolution to site / media metadatas
90-008 Feb 11, 2022
e467d47
refactor(chat): rename QueryHasPermission -> HasPermission
90-008 Feb 14, 2022
7514d4f
refactor: move PhotoInfo to harmonytypes as ImageInfo, use it in places
90-008 Feb 14, 2022
42d1d02
refactor(emote): add emote rpc shouldnt use emote itself
90-008 Feb 14, 2022
a2f1964
refactor(chat): use repeated Permission in HasPermissions, document G…
90-008 Feb 14, 2022
d923771
remove deprecated is_bot field
bluskript Feb 15, 2022
8084e42
move embeds and attachments out of extras
bluskript Feb 15, 2022
ff630bb
improve consistency: rename photo to image, add id field to mediaproxy
bluskript Feb 15, 2022
6b61f2e
fix(chat): make sendmessage.content consistent with content
90-008 Feb 20, 2022
af88d10
feat(chat): seperate ImageInfos again
90-008 Feb 20, 2022
828cefe
fix(mediaproxy): fix import
90-008 Feb 20, 2022
40c9d52
feat: remove is_bot
90-008 Feb 20, 2022
0c42f2f
feat(chat): make GetPermissions return guild perms seperately
90-008 Feb 21, 2022
858ed82
docs: fix ID documentations
90-008 Feb 26, 2022
1c923b5
refactor(chat): rework guild kinds
90-008 Feb 26, 2022
45d1662
feat(profile): extend user status by allowing it to contain activities
90-008 Feb 26, 2022
5c39069
refactor(chat): rework embeds
90-008 Feb 26, 2022
0fcff77
refactor: move ImageInfo's under their Attachment's, improve some com…
90-008 Feb 26, 2022
22fcfd7
feat: remove localization format
90-008 Feb 26, 2022
9c3798e
feat(chat): rework reactions
90-008 Feb 26, 2022
593ba50
feat(chat): rework UpdateMessageText into UpdateMessageContent
90-008 Feb 26, 2022
d963c67
feat: remove voice
sowelipililimute Feb 22, 2022
f67cbf8
feat: add webrtc service
sowelipililimute Feb 22, 2022
31ea189
feat(profile): add user notes app data type
90-008 Apr 2, 2022
9c39c99
feat: bot tokens (#99)
90-008 Apr 2, 2022
94b1112
feat: separate private channels from guilds (#100)
90-008 Apr 2, 2022
d9f35a3
feat: refactor actions (#101)
90-008 Apr 2, 2022
ac35c01
fix(chat): message name typo
90-008 Apr 2, 2022
6ad5b1d
fix(chat): add missing get private channel list rpc
90-008 Apr 2, 2022
a2d4082
fix(chat): remove unused import
90-008 Apr 2, 2022
90a1fc0
fix(chat): fix a few fields that need to be optional
90-008 Apr 3, 2022
ffb8ca8
fix(chat): typing request should have an optional guild id
90-008 Apr 3, 2022
6bbbadc
fix: fix location.guild_invite_id to be string, remove invite_id from…
90-008 Apr 6, 2022
f424aa0
fix: Invite* events should also use location
90-008 Apr 6, 2022
63b855f
feat(chat): add GetOutgoingPendingInvites to let users fetch the invi…
90-008 Apr 6, 2022
fb9028f
feat(chat): add DeleteOutgoingInvite to delete and cancel an outgoing…
90-008 Apr 6, 2022
14be6dd
fix(chat): Reject/Ignore pending invite requests should use PendingIn…
90-008 Apr 6, 2022
cc41fa8
feat(chat): allow specifying pack_id optionally in Emoji format
90-008 Apr 6, 2022
abd8124
refactor(chat): Invite* events should use Pending/Outgoing Invite
90-008 Apr 6, 2022
317b784
refactor(chat): make more server_ids optional
90-008 Apr 6, 2022
848b617
feat(sync): add inviter_id to user rejected invite
90-008 Apr 6, 2022
c964791
feat: remove outgoing invites, add join private channel
90-008 Apr 7, 2022
724cf95
fix(chat): remove outgoing invite usage
90-008 Apr 7, 2022
0981d97
fix(chat): add field names
90-008 Apr 7, 2022
87a9359
refactor(chat): make pending invite endpoints not use pending invite …
90-008 Apr 7, 2022
ca3ebac
docs(chat): document when a pending invite is unique
90-008 Apr 7, 2022
db38966
feat(chat): add leave private channel endpoint
90-008 Apr 7, 2022
64ea59e
refactor(chat): rename is_locked to is_dm, let create private channel…
90-008 Apr 7, 2022
772798b
refactor(chat): make another server id optional
90-008 Apr 7, 2022
b265a91
add private channel data to get rpc, add optional name
bluskript Apr 10, 2022
b47c27f
separate private channel fetching and its data
bluskript Apr 10, 2022
598e413
refactor(chat): GetPrivateChannelData -> GetPrivateChannel
90-008 Apr 10, 2022
e438b77
refactor(chat): dont use optional name in UpdatePrivateChannelNameReq…
90-008 Apr 10, 2022
a1319c7
feat(chat): consolidate UpdatePrivateChannel\* RPCs into one, add Pri…
90-008 Apr 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: bot tokens (#99)
Co-authored-by: spiral <[email protected]>
  • Loading branch information
90-008 and spiral authored Apr 2, 2022
commit 9c39c99090c29939d7300b62e34e9eaa4fc2961f
4 changes: 4 additions & 0 deletions stable/auth/v1/auth.proto
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ message CheckLoggedInResponse {}
// TODO: finish

// The service containing authorization/entication methods.
//
// It is important to note that bots are exempt from AuthService
// - a persistent authorization token is generated on bot creation.
// This is handled in BotsService.
service AuthService {
// Federate with a foreignserver, obtaining a token
// you can use to call LoginFederated on it.
Expand Down
36 changes: 20 additions & 16 deletions stable/chat/v1/chat.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "chat/v1/channels.proto";
import "chat/v1/messages.proto";
import "chat/v1/permissions.proto";
import "chat/v1/stream.proto";
import "chat/v1/private_channel.proto";

package protocol.chat.v1;

Expand All @@ -16,29 +17,32 @@ service ChatService {
option (harmonytypes.v1.metadata).requires_authentication = true;
}

// Endpoint to create a "room" guild.
rpc CreateRoom(CreateRoomRequest) returns (CreateRoomResponse) {
option (harmonytypes.v1.metadata).requires_authentication = true;
}

// Endpoint to create a "direct message" guild.
// Endpoint to create a private channel.
//
// - The inviter and the invitee that join the created guild will both be owners.
// - The guild should be created on the server that the inviter is on.
// - The server should send a guild invite to the invitee (specified in the request),
// using the `UserInvited` postbox event if the invitee is on another server.
// - The server should send an invite to the invitee(s) (specified in the request),
// using the `UserInvited` postbox event if the invitee(s) are on another server.
// - The receiving server should process this as follows: adding the invite to their pending
// invite list and sending an `InviteReceived` event over their event stream if
// the invitee is on this server.
// - The invitee may or may not use the invite. Only the invitee may use the invite.
rpc CreateDirectMessage(CreateDirectMessageRequest) returns (CreateDirectMessageResponse) {
// the invitee(s) are on this server.
// - The invitee(s) may or may not use the invite. Only the invitee(s) may use the invite.
rpc CreatePrivateChannel(CreatePrivateChannelRequest) returns (CreatePrivateChannelResponse) {
option (harmonytypes.v1.metadata).requires_authentication = true;
}

// Endpoint to upgrade a "room" guild to a "normal" guild.
rpc UpgradeRoomToGuild(UpgradeRoomToGuildRequest) returns (UpgradeRoomToGuildResponse) {
// Endpoint to modify the member list of a private channel.
//
// - This is only possible if the channel's `is_locked` property is set to false.
// - The server should send an invite to the added members (if any).
// This should follow the same invite sending logic in `CreatePrivateChannel`.
rpc UpdatePrivateChannelMembers(UpdatePrivateChannelMembersRequest) returns (UpdatePrivateChannelMembersResponse) {
option (harmonytypes.v1.metadata).requires_authentication = true;
}

// Endpoint to delete a private channel.
//
// Only the user who created the private channel can delete it.
rpc DeletePrivateChannel(DeletePrivateChannelRequest) returns (DeletePrivateChannelResponse) {
option (harmonytypes.v1.metadata).requires_authentication = true;
option (harmonytypes.v1.metadata).requires_owner = true;
}

// Endpoint to create an invite.
Expand Down
64 changes: 1 addition & 63 deletions stable/chat/v1/guilds.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,6 @@ import "harmonytypes/v1/types.proto";

// Object representing a guild without the ID part.
message Guild {
// The kind of a guild.
enum Kind {
// A "normal" guild as in a guild that allows multiple channels.
KIND_NORMAL_UNSPECIFIED = 0;
// A "room" guild as in a guild that only has one channel.
//
// - Clients should not show a channel list for guilds of this type.
KIND_ROOM = 1;
// A "direct message" guild as in a guild that has at most two members,
// and has only one channel.
//
// - Clients should not show a channel list for guilds of this type.
// - Clients should show this guild in the guild list with the profile picture
// and the username of the other user.
// - Servers should "upgrade" this guild to a "room" guild if another
// user joins the guild. A name should be crafted using the algorithm
// described below:
// - Get at most 3 members' usernames, by their
// - Concat them with ", " as a seperator.
KIND_DIRECT_MESSAGE = 2;
}

// The name of the guild.
//
// This will be empty if the guild kind is "direct message". See
Expand All @@ -38,10 +16,8 @@ message Guild {
optional string picture = 2;
// User ID of the owners of the guild.
repeated uint64 owner_ids = 3;
// The kind of this guild.
Kind kind = 4;
// Metadata of the guild.
optional harmonytypes.v1.Metadata metadata = 5;
optional harmonytypes.v1.Metadata metadata = 4;
}

// Object representing a guild with the ID part.
Expand Down Expand Up @@ -111,36 +87,6 @@ message CreateGuildResponse {
uint64 guild_id = 1;
}

// Request type used in `CreateRoom` endpoint.
message CreateRoomRequest {
// The name of the guild.
string name = 1;
// The picture file ID of the guild.
optional string picture = 2;
// Metadata of the guild.
optional harmonytypes.v1.Metadata metadata = 3;
}
// Used in the `CreateRoom` endpoint.
message CreateRoomResponse {
// Guild ID of the guild that was created.
uint64 guild_id = 1;
}

// Used in the `CreateDirectMessage` endpoint.
message CreateDirectMessageRequest {
// The user name of the user to DM with.
string user_name = 1;
// The server ID of the server the user is on.
//
// Should be left unspecified if it's a user on the homeserver.
optional string server_id = 2;
}
// Used in the `CreateDirectMessage` endpoint.
message CreateDirectMessageResponse {
// Guild ID of the just created "direct message" guild.
uint64 guild_id = 1;
}

// Used in the `CreateInvite` endpoint.
message CreateInviteRequest {
// Guild ID of the guild to create an invite in.
Expand Down Expand Up @@ -213,14 +159,6 @@ message UpdateGuildInformationRequest {
// Used in the `UpdateGuildInformation` endpoint.
message UpdateGuildInformationResponse {}

// Used in the `UpgradeRoomToGuild` endpoint.
message UpgradeRoomToGuildRequest {
// Guild ID of the "room" guild to upgrade to a "normal" guild.
uint64 guild_id = 1;
}
// Used in the `UpgradeRoomToGuild` endpoint.
message UpgradeRoomToGuildResponse {}

// Used in the `DeleteGuild` endpoint.
message DeleteGuildRequest {
// Guild ID of the guild you want to delete.
Expand Down
87 changes: 34 additions & 53 deletions stable/chat/v1/messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,11 @@ message Overrides {
}
}

// The payload sent to the bot when an action is triggered.
message ActionPayload {
// The payload data for a button action.
message Button {
// The data from the Button action.
bytes data = 1;
}
// The payload for a dropdown action.
message Dropdown {
// The user choice from the dropdown.
bytes choice = 1;
}
// The payload for a text input action.
message Input {
// The user input.
string input = 1;
// The bot-provided data.
bytes data = 2;
}
// The payload data.
oneof payload {
// Payload for a button.
Button button = 1;
// Payload for a dropdown.
Dropdown dropdown = 2;
// Payload for a text input.
Input input = 3;
}
}

// Actions are interactive elements that can exist within an embed.
// Actions are interactive elements that can exist within a message.
// They can be only sent by bots; servers should ignore actions created by users.
//
// Servers MUST verify that the action data sent by an user is valid for that action
// before sending it to the bot.
message Action {
// The action type. This is primarily used to change the look of the action to
// the user (example: Destructive actions will have a red background).
Expand All @@ -78,14 +52,11 @@ message Action {
// The text to show on the button.
string text = 1;

// Action data, which should be used in the call to perform the action.
bytes data = 2;

// An external URL that the button links to.
//
// This makes it so that tapping this button will open said URL instead
// of triggering the action.
optional string url = 3;
optional string url = 2;
}

// A dropdown menu that users can click on to trigger an action.
Expand All @@ -111,21 +82,24 @@ message Action {
string label = 1;
// Whether this text input should be a multiline one or not.
bool multiline = 2;
// Contextual data allowing the bot to discern what the user input is for.
bytes data = 3;
// The default text that should be pre-filled in the text field.
optional string default = 3;
}

// Type of the action.
Type action_type = 1;
// Contextual info allowing the bot to discern what the action is for.
// The info of an action cannot be the same with the info of another action in the same message.
bytes info = 2;

// The kind of the action.
oneof kind {
// Button action.
Button button = 2;
Button button = 3;
// Dropdown action.
Dropdown dropdown = 3;
Dropdown dropdown = 4;
// Input action.
Input input = 4;
Input input = 5;
}
}

Expand Down Expand Up @@ -440,6 +414,8 @@ message Message {
Content content = 7;
// The reactions of the message.
repeated Reaction reactions = 8;
// Bot actions to show on this message.
repeated Action actions = 9;
}

// Object representing a message with it's ID.
Expand All @@ -463,7 +439,7 @@ message GetChannelMessagesRequest {
}

// Guild ID of the guild that has the channel.
uint64 guild_id = 1;
optional uint64 guild_id = 1;
// Channel ID of the channel to get messages from.
uint64 channel_id = 2;
// The ID of the message that will be used as an "anchor" point to figure out
Expand Down Expand Up @@ -505,7 +481,7 @@ message GetChannelMessagesResponse {
// Used in the `GetMessage` endpoint.
message GetMessageRequest {
// Guild ID of the guild where the channel is.
uint64 guild_id = 1;
optional uint64 guild_id = 1;
// Channel ID of the channel where the message is.
uint64 channel_id = 2;
// Message ID of the message you want to get.
Expand All @@ -520,7 +496,7 @@ message GetMessageResponse {
// Used in the `DeleteMessage` endpoint.
message DeleteMessageRequest {
// Guild ID of the guild where the channel is.
uint64 guild_id = 1;
optional uint64 guild_id = 1;
// Channel ID of the channel where the message is.
uint64 channel_id = 2;
// Message ID of the message you want to delete.
Expand All @@ -532,13 +508,16 @@ message DeleteMessageResponse {}
// Used in the `TriggerAction` endpoint.
message TriggerActionRequest {
// Guild ID of the guild where the channel is.
uint64 guild_id = 1;
optional uint64 guild_id = 1;
// Channel ID of the channel where the message is.
uint64 channel_id = 2;
// Message ID of the message you want to trigger an action in.
uint64 message_id = 3;
// Payload of action data.
ActionPayload payload = 4;
// Data that alllows the bot to discern which action the user is trying to trigger.
// A server MUST verify that this info refers to a valid action for the target message.
bytes info = 4;
// Payload of action data. Ignored if this is a button action.
optional bytes payload = 5;
}
// Used in the `TriggerAction` endpoint.
message TriggerActionResponse {}
Expand Down Expand Up @@ -591,7 +570,7 @@ message SendMessageRequest {
}

// Guild ID of the guild where the channel is.
uint64 guild_id = 1;
optional uint64 guild_id = 1;
// Channel ID of the channel you want to send a message in.
uint64 channel_id = 2;
// Content of the new message.
Expand All @@ -604,6 +583,8 @@ message SendMessageRequest {
optional Overrides overrides = 6;
// The message this new message is a reply to.
optional uint64 in_reply_to = 7;
// Actions to send on this message. Ignored if the message is not sent by a bot.
repeated Action actions = 8;
// The metadata of this new message.
optional harmonytypes.v1.Metadata metadata = 5;
}
Expand All @@ -616,7 +597,7 @@ message SendMessageResponse {
// Used in the `UpdateMessageContent` endpoint.
message UpdateMessageContentRequest {
// Guild ID of the guild where the channel is.
uint64 guild_id = 1;
optional uint64 guild_id = 1;
// Channel ID of the channel where the message is.
uint64 channel_id = 2;
// Message ID of the message you want to change the content of.
Expand All @@ -630,7 +611,7 @@ message UpdateMessageContentResponse {}
// Used in the `PinMessage` endpoint.
message PinMessageRequest {
// Guild ID of the guild where the channel is.
uint64 guild_id = 1;
optional uint64 guild_id = 1;
// Channel ID of the channel where the message is.
uint64 channel_id = 2;
// Message ID of the message we want to pin.
Expand All @@ -642,7 +623,7 @@ message PinMessageResponse {}
// Used in the `UnpinMessage` endpoint.
message UnpinMessageRequest {
// Guild ID of the guild where the channel is.
uint64 guild_id = 1;
optional uint64 guild_id = 1;
// Channel ID of the channel where the message is.
uint64 channel_id = 2;
// Message ID of the message we want to unpin.
Expand All @@ -654,7 +635,7 @@ message UnpinMessageResponse {}
// Used in the `GetPinnedMessages` endpoint.
message GetPinnedMessagesRequest {
// Guild ID of the guild where the channel is.
uint64 guild_id = 1;
optional uint64 guild_id = 1;
// Channel ID of the channel we want to get pins of.
uint64 channel_id = 2;
}
Expand All @@ -668,7 +649,7 @@ message GetPinnedMessagesResponse {
// Used in `AddReaction` endpoint.
message AddReactionRequest {
// Guild ID of the guild where the channel is.
uint64 guild_id = 1;
optional uint64 guild_id = 1;
// Channel ID of the channel where the message is.
uint64 channel_id = 2;
// Message ID of the message we want to add a reaction to.
Expand All @@ -686,7 +667,7 @@ message AddReactionResponse {}
// Used in `RemoveReaction` endpoint.
message RemoveReactionRequest {
// Guild ID of the guild where the channel is.
uint64 guild_id = 1;
optional uint64 guild_id = 1;
// Channel ID of the channel where the message is.
uint64 channel_id = 2;
// Message ID of the message we want to remove a reaction.
Expand Down
Loading