syntax = "proto3"; import "harmonytypes/v1/types.proto"; import "chat/v1/guilds.proto"; import "chat/v1/channels.proto"; import "chat/v1/messages.proto"; import "chat/v1/permissions.proto"; import "chat/v1/stream.proto"; package protocol.chat.v1; option go_package = "github.com/harmony-development/legato/gen/chat/v1"; // The core of Harmony's chat operations. service ChatService { // Endpoint to create a guild. rpc CreateGuild(CreateGuildRequest) returns (CreateGuildResponse) { 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. // // - The inviter and the invitee that join the created guild will both be owners. // - The guild should be created on the server that 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, // otherwise see the below item. // - The 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) { option (harmonytypes.v1.metadata).requires_authentication = true; } // Endpoint to upgrade a "room" guild to a "normal" guild. rpc UpgradeRoomToGuild(UpgradeRoomToGuildRequest) returns (UpgradeRoomToGuildResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_owner = true; } // Endpoint to create an invite. rpc CreateInvite(CreateInviteRequest) returns (CreateInviteResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "invites.manage.create"; } // Endpoint to create a channel. rpc CreateChannel(CreateChannelRequest) returns (CreateChannelResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "channels.manage.create"; } // Endpoint to get your guild list. rpc GetGuildList(GetGuildListRequest) returns (GetGuildListResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; } // Endpoint to invite a user to a guild. rpc InviteUserToGuild(InviteUserToGuildRequest) returns (InviteUserToGuildResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "invites.manage.create"; } // Endpoint to get your pending invites. rpc GetPendingInvites(GetPendingInvitesRequest) returns (GetPendingInvitesResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; } // Endpoint to reject (delete with notification to the inviter) an invite // from your pending invite list. // // If the invitee is on a different server than the inviter, the invitee's // server should send a `UserRejectedInvite` postbox event to the inviter's // server. // // The "notification" is sending a `InviteRejected` stream event to the // inviter. If the guild's kind is `DirectMessage`, the server should also // set the `rejected` field of the guild's kind to `true`. rpc RejectPendingInvite(RejectPendingInviteRequest) returns (RejectPendingInviteResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; } // Endpoint to ignore (delete without notification to the inviter) an // invite from your pending invite list. rpc IgnorePendingInvite(IgnorePendingInviteRequest) returns (IgnorePendingInviteResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; } // Endpoint to get information about a guild. rpc GetGuild(GetGuildRequest) returns (GetGuildResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; } // Endpoint to get the invites of a guild. // // This requires the "invites.view" permission. rpc GetGuildInvites(GetGuildInvitesRequest) returns (GetGuildInvitesResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "invites.view"; } // Endpoint to get the members of a guild. rpc GetGuildMembers(GetGuildMembersRequest) returns (GetGuildMembersResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; } // Endpoint to get the channels of a guild. // // You will only be informed of channels you have the "messages.view" // permission for. rpc GetGuildChannels(GetGuildChannelsRequest) returns (GetGuildChannelsResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; } // Endpoint to get the messages from a guild channel. rpc GetChannelMessages(GetChannelMessagesRequest) returns (GetChannelMessagesResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "messages.view"; } // Endpoint to get a single message from a guild channel. rpc GetMessage(GetMessageRequest) returns (GetMessageResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "messages.view"; } // Endpoint to update a guild's information. rpc UpdateGuildInformation(UpdateGuildInformationRequest) returns (UpdateGuildInformationResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "guild.manage.change-information"; } // Endpoint to update a channel's information. rpc UpdateChannelInformation(UpdateChannelInformationRequest) returns (UpdateChannelInformationResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "channels.manage.change-information"; } // Endpoint to change the position of a channel in the channel list. rpc UpdateChannelOrder(UpdateChannelOrderRequest) returns (UpdateChannelOrderResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "channels.manage.move"; } // Endpoint to change the position of all channels in the guild; // must specifcy all channels or fails rpc UpdateAllChannelOrder(UpdateAllChannelOrderRequest) returns (UpdateAllChannelOrderResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "channels.manage.move"; } // Endpoint to change the text of a message. rpc UpdateMessageText(UpdateMessageTextRequest) returns (UpdateMessageTextResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "messages.send"; } // Endpoint to delete a guild. // Can only be invoked if there's one owner. rpc DeleteGuild(DeleteGuildRequest) returns (DeleteGuildResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_owner = true; } // Endpoint to delete an invite. rpc DeleteInvite(DeleteInviteRequest) returns (DeleteInviteResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "invites.manage.delete"; } // Endpoint to delete a channel. rpc DeleteChannel(DeleteChannelRequest) returns (DeleteChannelResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "channels.manage.delete"; } // Endpoint to delete a message. // // This requires the "messages.manage.delete" permission if you are not the // message author. rpc DeleteMessage(DeleteMessageRequest) returns (DeleteMessageResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; } // Endpoint to join a guild. // // - If the invite used is in a user's "pending invites" list, it should be // removed from there. rpc JoinGuild(JoinGuildRequest) returns (JoinGuildResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; } // Endpoint to leave a guild. // // - If you're the only owner, you can't leave a guild. Exception to this // rule are "direct message" guilds. // - When the last member in a "direct message" guild leaves it, that guild // should be deleted. rpc LeaveGuild(LeaveGuildRequest) returns (LeaveGuildResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; } // Endpont to trigger an action. rpc TriggerAction(TriggerActionRequest) returns (TriggerActionResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "actions.trigger"; } // Endpoint to send a message. rpc SendMessage(SendMessageRequest) returns (SendMessageResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "messages.send"; } // Endpoint to query if a user has a permission. rpc QueryHasPermission(QueryHasPermissionRequest) returns (QueryHasPermissionResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; // This permissions node is only required if you're trying // to see if someone besides yourself has a permission. // // option (harmonytypes.v1.metadata).requires_permission_node = // "permissions.query"; } // Endpoint to set permissions for a role in a guild. rpc SetPermissions(SetPermissionsRequest) returns (SetPermissionsResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "permissions.manage.set"; } // Endpoint to get permissions for a role in a guild. rpc GetPermissions(GetPermissionsRequest) returns (GetPermissionsResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "permissions.manage.get"; } // Endpoint to change the position of a role in the role list in a guild. rpc MoveRole(MoveRoleRequest) returns (MoveRoleResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "roles.manage"; } // Endpoint to get the roles from a guild. rpc GetGuildRoles(GetGuildRolesRequest) returns (GetGuildRolesResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "roles.get"; } // Endpoint to add a role to a guild. rpc AddGuildRole(AddGuildRoleRequest) returns (AddGuildRoleResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "roles.manage"; } // Endpoint to a modify a role from a guild. rpc ModifyGuildRole(ModifyGuildRoleRequest) returns (ModifyGuildRoleResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "roles.manage"; } // Endpoint to delete a role from a guild. rpc DeleteGuildRole(DeleteGuildRoleRequest) returns (DeleteGuildRoleResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "roles.manage"; } // Endpoint to manage the roles of a guild member. rpc ManageUserRoles(ManageUserRolesRequest) returns (ManageUserRolesResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "roles.user.manage"; } // Endpoint to get the roles a guild member has. rpc GetUserRoles(GetUserRolesRequest) returns (GetUserRolesResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; // This permissions node is only required if you are trying to get the roles // of someone other than yourself. // // option (harmonytypes.v1.metadata).requires_permission_node = // "roles.user.get"; } // Endpoint to send a typing notification in a guild channel. rpc Typing(TypingRequest) returns (TypingResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "messages.send"; } // Endpoint to "preview" a guild, which returns some information about a // guild. // // - Guilds with the "direct message" kind can only be previewed // by the user who is invited to the guild. rpc PreviewGuild(PreviewGuildRequest) returns (PreviewGuildResponse) { option (harmonytypes.v1.metadata).requires_authentication = false; } // Endpoint to get banned users in a guild. rpc GetBannedUsers(GetBannedUsersRequest) returns (GetBannedUsersResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "guild.manage.change-information"; } // Endpoint to ban a user from a guild. rpc BanUser(BanUserRequest) returns (BanUserResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "user.manage.ban"; } // Endpoint to kick a user from a guild. rpc KickUser(KickUserRequest) returns (KickUserResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "user.manage.kick"; } // Endpoint to unban a user from a guild. rpc UnbanUser(UnbanUserRequest) returns (UnbanUserResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "user.manage.unban"; } // Endpoint to get all pinned messages in a guild channel. rpc GetPinnedMessages(GetPinnedMessagesRequest) returns (GetPinnedMessagesResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "messages.view"; } // Endpoint to pin a message in a guild channel. rpc PinMessage(PinMessageRequest) returns (PinMessageResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "messages.pins.add"; } // Endpoint to unpin a message in a guild channel. rpc UnpinMessage(UnpinMessageRequest) returns (UnpinMessageResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "messages.pins.remove"; } // Endpoint to stream events from the homeserver. // 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 rpc StreamEvents(stream StreamEventsRequest) returns (stream StreamEventsResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; } // Endpoint to add a reaction to a message. rpc AddReaction(AddReactionRequest) returns (AddReactionResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "messages.reactions.add"; } // Endpoint to remove a reaction from a message. rpc RemoveReaction(RemoveReactionRequest) returns (RemoveReactionResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_permission_node = "messages.reactions.remove"; } /// OWNERS // Endpoint to give ownership to someone else. rpc GrantOwnership(GrantOwnershipRequest) returns (GrantOwnershipResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_owner = true; } // Endpoint to give up your own ownership. // Requires that at least one other person will still be owner. rpc GiveUpOwnership(GiveUpOwnershipRequest) returns (GiveUpOwnershipResponse) { option (harmonytypes.v1.metadata).requires_authentication = true; option (harmonytypes.v1.metadata).requires_owner = true; } }