diff --git a/stable/chat/v1/chat.proto b/stable/chat/v1/chat.proto index e03c94d..3b35c6d 100644 --- a/stable/chat/v1/chat.proto +++ b/stable/chat/v1/chat.proto @@ -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; @@ -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. diff --git a/stable/chat/v1/guilds.proto b/stable/chat/v1/guilds.proto index 1138182..558c605 100644 --- a/stable/chat/v1/guilds.proto +++ b/stable/chat/v1/guilds.proto @@ -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 @@ -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. @@ -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. @@ -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. diff --git a/stable/chat/v1/messages.proto b/stable/chat/v1/messages.proto index 59ead8a..53188ec 100644 --- a/stable/chat/v1/messages.proto +++ b/stable/chat/v1/messages.proto @@ -463,7 +463,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 @@ -505,7 +505,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. @@ -520,7 +520,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. @@ -532,7 +532,7 @@ 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. @@ -591,7 +591,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. @@ -616,7 +616,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. @@ -630,7 +630,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. @@ -642,7 +642,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. @@ -654,7 +654,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; } @@ -668,7 +668,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. @@ -686,7 +686,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. diff --git a/stable/chat/v1/private_channel.proto b/stable/chat/v1/private_channel.proto new file mode 100644 index 0000000..b30096a --- /dev/null +++ b/stable/chat/v1/private_channel.proto @@ -0,0 +1,68 @@ +syntax = "proto3"; + +package protocol.chat.v1; + +// PrivateChannel is a private channel between a list of users, independent of a guild. +// It should be possible to use this channel for both text and voice communications. +message PrivateChannel { + // The list of users that have access to this channel. + repeated uint64 members = 1; + // Whether it is possible to add or remove users to/from this channel. + // + // If a channel is locked, the number of recipients is two (this is a direct message channel). + // It should not be possible to have multiple direct message channels between the same two users. + bool is_locked = 2; +} + +// An entry in the list of private channels. +message PrivateChannelListEntry { + // The channel ID of this channel list entry. + uint64 channel_id = 1; + // The server ID of the homeserver of this private channel. + string server_id = 2; +} + +// Request type used in `CreatePrivateChannel` endpoint. +message CreatePrivateChannelRequest { + // The list of users that have access to this channel. + // + // These users will be sent an invite. + repeated uint64 members = 1; + // Whether it is possible to add or remove users to/from this channel. + bool is_locked = 2; +} +// Response type used in `CreatePrivateChannel` endpoint. +message CreatePrivateChannelResponse { + // The channel ID of the newly created private channel. + uint64 channel_id = 1; +} + +// Request type used in `UpdatePrivateChannelMembers` endpoint. +message UpdatePrivateChannelMembersRequest { + // The channel ID of the private channel to update the member list for. + uint64 channel_id = 1; + // The list of member IDs of members to add to the private channel. + // + // These users will be sent an invite. + repeated uint64 added_members = 2; + // The list of member IDs of members to remove from the private channel. + repeated uint64 removed_members = 3; +} +// Request type used in `UpdatePrivateChannelMembers` endpoint. +message UpdatePrivateChannelMembersResponse {} + +// Request type used in `DeletePrivateChannel` endpoint. +message DeletePrivateChannelRequest { + // The channel ID of the private channel to delete. + uint64 channel_id = 1; +} +// Response type used in `DeletePrivateChannel` endpoint. +message DeletePrivateChannelResponse {} + +// Request type used in `GetPrivateChannels` endpoint. +message GetPrivateChannelsRequest {} +// Response type used in `GetPrivateChannels` endpoint. +message GetPrivateChannelsResponse { + // The list of private channels that the user is in. + repeated PrivateChannelListEntry channels = 1; +} \ No newline at end of file diff --git a/stable/chat/v1/stream.proto b/stable/chat/v1/stream.proto index 66bc899..130c38a 100644 --- a/stable/chat/v1/stream.proto +++ b/stable/chat/v1/stream.proto @@ -7,36 +7,44 @@ import "chat/v1/channels.proto"; import "chat/v1/guilds.proto"; import "chat/v1/messages.proto"; import "chat/v1/permissions.proto"; +import "chat/v1/private_channel.proto"; import "emote/v1/stream.proto"; import "profile/v1/stream.proto"; // Request type for use in the `StreamEvents` endpoint. // By default, this endpoint will subscribe to all events. -// Any guilds joined in the future will be added to the subscription as well. -// Use the UnsubscribeFromAll event for unsubscribing from all current subscriptions and disable the automatic guild subscriptions +// Any guilds / private channels joined in the future will be added to the subscription as well. +// Use the UnsubscribeFromAll event for unsubscribing from all current subscriptions and disable the automatic guild subscriptions. message StreamEventsRequest { - // Event source for guilds' events. + // Message to use for subscribing to a guild. message SubscribeToGuild { - // the guild id to subscribe to + // The guild ID to subscribe to. uint64 guild_id = 1; } - // Event source for actions' events. + // Message to use for subscribing to a private channel. + message SubscribeToPrivateChannel { + // The channel ID to subscribe to. + uint64 channel_id = 1; + } + // Message to use for subscribing to actions. message SubscribeToActions {} - // Event source for homeserver events. + // Message to use for subscribing to homeserver events. message SubscribeToHomeserverEvents {} - // Event to unsubscribe from all events. + // Message to use for unsubscribing from all events. message UnsubscribeFromAll {} // Describes which event source to subscribe to. oneof request { - // Subscribe to the guild event source. + // Subscribe to guild events. SubscribeToGuild subscribe_to_guild = 1; - // Subscribe to the action event source. - SubscribeToActions subscribe_to_actions = 2; - // Subscribe to the homeserver event source. - SubscribeToHomeserverEvents subscribe_to_homeserver_events = 3; + // Subscribe to private channel events. + SubscribeToPrivateChannels subscribe_to_private_channels = 2; + // Subscribe to action events. + SubscribeToActions subscribe_to_actions = 3; + // Subscribe to homeserver events. + SubscribeToHomeserverEvents subscribe_to_homeserver_events = 4; // Unsubscribe from all events. - UnsubscribeFromAll unsubscribe_from_all = 4; + UnsubscribeFromAll unsubscribe_from_all = 5; } } @@ -63,7 +71,8 @@ message StreamEvent { // ID that is sent by your client it can use to confirm that the message is sent. optional uint64 echo_id = 1; // Guild ID of the guild where this event happened. - uint64 guild_id = 2; + // Null if the event happened in a private channel. + optional uint64 guild_id = 2; // Channel ID of the channel where this event happened. uint64 channel_id = 3; // Message ID of the message that was updated. @@ -78,7 +87,8 @@ message StreamEvent { // for the channel the message was updated in. message MessageUpdated { // Guild ID of the guild where this event happened. - uint64 guild_id = 1; + // Null if the event happened in a private channel. + optional uint64 guild_id = 1; // Channel ID of the channel where this event happened. uint64 channel_id = 2; // Message ID of the message that was updated. @@ -95,7 +105,7 @@ message StreamEvent { // for the channel the message was deleted in. message MessageDeleted { // Guild ID of the guild where this event happened. - uint64 guild_id = 1; + optional uint64 guild_id = 1; // Channel ID of the channel where this event happened. uint64 channel_id = 2; // Message ID of the message that was deleted. @@ -105,7 +115,7 @@ message StreamEvent { // Event sent when a new channel is created. message ChannelCreated { // Guild ID of the guild where this event happened. - uint64 guild_id = 1; + optional uint64 guild_id = 1; // Channel ID of the channel where this event happened. uint64 channel_id = 2; // Name of this channel. @@ -208,16 +218,16 @@ message StreamEvent { message GuildAddedToList { // Guild ID of the guild where this event happened. uint64 guild_id = 1; - // The homeserver this guild is on. - string homeserver = 2; + // The server ID of the homeserver this guild is on. + string server_id = 2; } // Event sent when you leave a guild. message GuildRemovedFromList { // Guild ID of the guild where this event happened. uint64 guild_id = 1; - // The homeserver this guild is on. - string homeserver = 2; + // The server ID homeserver this guild is on. + string server_id = 2; } // Event sent when an action is performed. @@ -326,7 +336,7 @@ message StreamEvent { // User ID of the user that sent the typing notification. uint64 user_id = 1; // Guild ID of the guild where this event happened. - uint64 guild_id = 2; + optional uint64 guild_id = 2; // Channel ID of the channel where this event happened. uint64 channel_id = 3; } @@ -352,7 +362,7 @@ message StreamEvent { // the guild channel where the message was pinned. message MessagePinned { // Guild ID of the guild where this event occured. - uint64 guild_id = 1; + optional uint64 guild_id = 1; // Channel ID of the channel where this event occured. uint64 channel_id = 2; // Message ID of the message that was pinned. @@ -365,7 +375,7 @@ message StreamEvent { // the guild channel where the message was unpinned. message MessageUnpinned { // Guild ID of the guild where this event occured. - uint64 guild_id = 1; + optional uint64 guild_id = 1; // Channel ID of the channel where this event occured. uint64 channel_id = 2; // Message ID of the message that was unpinned. @@ -379,7 +389,7 @@ message StreamEvent { // the guild channel where the reaction was added. message NewReactionAdded { // Guild ID of the guild where this event occured. - uint64 guild_id = 1; + optional uint64 guild_id = 1; // Channel ID of the channel where this event occured. uint64 channel_id = 2; // Message ID of the message that had a reaction added. @@ -492,6 +502,41 @@ message StreamEvent { uint64 user_id = 3; } + // Sent when a private channel is deleted. + message PrivateChannelDeleted { + // The channel ID of the private channel that was deleted. + uint64 channel_id = 1; + } + + // Sent when a private channel is added to an user's private channel list. + message PrivateChannelAddedToList { + // The channel ID of the private channel that was added. + uint64 channel_id = 1; + // The server ID of the homeserver of this private channel. + string server_id = 2; + } + // Sent when a private channel is removed from an user's private channel list. + message PrivateChannelRemovedFromList { + // The channel ID of the private channel that was removed. + uint64 channel_id = 1; + // The server ID of the homeserver of this private channel. + string server_id = 2; + } + // Sent when a user joins a private channel. + message UserJoinedPrivateChannel { + // The channel ID of the private channel. + uint64 channel_id = 1; + // The user ID of the user who joined the private channel. + uint64 user_id = 2; + } + // Sent when a user leaves a private channel. + message UserLeftPrivateChannel { + // The channel ID of the private channel. + uint64 channel_id = 1; + // The user ID of the user who left the private channel. + uint64 user_id = 2; + } + // Which event to send. oneof event { // Send the guild added to list event. @@ -564,5 +609,15 @@ message StreamEvent { ReactionAdded reaction_added = 34; // Send the reaction removed event. ReactionRemoved reaction_removed = 35; + // Send the private channel deleted event. + PrivateChannelDeleted private_channel_deleted = 36; + // Send the private channel added to list event. + PrivateChannelAddedToList private_channel_added_to_list = 37; + // Send the private channel removed from list event. + PrivateChannelRemovedFromList private_channel_removed_from_list = 38; + // Send the user joined private channel event. + UserJoinedPrivateChannel user_joined_private_channel = 39; + // Send the user left private channel event. + UserLeftPrivateChannel user_left_private_channel = 40; } } diff --git a/stable/sync/v1/sync.proto b/stable/sync/v1/sync.proto index e232395..4a98f3b 100644 --- a/stable/sync/v1/sync.proto +++ b/stable/sync/v1/sync.proto @@ -31,24 +31,53 @@ message Event { // Guild ID of the guild where the user will be. uint64 guild_id = 2; } + + // Event sent when an user is removed from a private channel. + message UserRemovedFromChannel { + // User ID of the user that was removed. + uint64 user_id = 1; + // Channel ID of the channel where the user was. + uint64 channel_id = 2; + } + // Event sent when an user is added to a private channel. + message UserAddedToChannel { + // User ID of the user that was added. + uint64 user_id = 1; + // Channel ID of the channel where the user will be. + uint64 channel_id = 2; + } + // Event sent when a user is invited to a guild. message UserInvited { // User ID of the invitee. uint64 user_id = 1; // User ID of the user that invited. uint64 inviter_id = 2; + + // The location where the user is being invited to. + oneof location { // The unique identifier of a user's invite to another // user to join a given guild. - string invite_id = 3; + uint64 guild_invite_id = 3; + // The channel ID of the private channel that the user was invited to. + uint64 channel_id = 4; + } } // Event sent when a user rejects a guild invitation. message UserRejectedInvite { - // Guild ID of the guild the invitee rejected an invite for. - uint64 guild_id = 1; // User ID of the invitee that rejected the invitation. - uint64 user_id = 2; + uint64 user_id = 1; // Invite ID of the invite that was rejected. - string invite_id = 3; + string invite_id = 2; + + // The location where the user was invited to. + oneof location { + // The unique identifier of a user's invite to another + // user to join a given guild. + uint64 guild_invite_id = 3; + // The channel ID of the private channel that the user was invited to. + uint64 channel_id = 4; + } } // The kind and data of this event. @@ -57,10 +86,14 @@ message Event { UserRemovedFromGuild user_removed_from_guild = 1; // User added to a guild. UserAddedToGuild user_added_to_guild = 2; + // User removed from a private channel. + UserRemovedFromChannel user_removed_from_channel = 3; + // User added to a private channel. + UserAddedToChannel user_added_to_channel = 4; // User invited to a guild. - UserInvited user_invited = 3; + UserInvited user_invited = 5; // User rejected a guild invitation. - UserRejectedInvite user_rejected_invite = 4; + UserRejectedInvite user_rejected_invite = 6; } } diff --git a/staging/bots/v1/bots.proto b/staging/bots/v1/bots.proto index 54f8860..55d8dbb 100644 --- a/staging/bots/v1/bots.proto +++ b/staging/bots/v1/bots.proto @@ -95,11 +95,18 @@ message PoliciesResponse { // Request type for AddBot. message AddBotRequest { - // The guild to add the bot to. - uint64 guild_id = 1; // The bot's invite code. - string invite_code = 2; + string invite_code = 1; + + // The location where the bot is being added to. + oneof location { + // The guild to add the bot to. + uint64 guild_id = 2; + // The private channel to add the bot to. + uint64 channel_id = 3; + } } + // Response type for AddBot. message AddBotResponse {}