Skip to content
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

feat: separate private channels from guilds #100

Merged
merged 1 commit into from
Apr 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
22 changes: 11 additions & 11 deletions stable/chat/v1/messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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;
}
Expand All @@ -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.
Expand All @@ -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.
Expand Down
68 changes: 68 additions & 0 deletions stable/chat/v1/private_channel.proto
Original file line number Diff line number Diff line change
@@ -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;
}
Loading