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

refactor: reorganize social service protos, and remove duplication #241

Merged
merged 2 commits into from
Jan 21, 2025
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
162 changes: 0 additions & 162 deletions proto/decentraland/social/friendships/friendships.proto

This file was deleted.

121 changes: 84 additions & 37 deletions proto/decentraland/social_service/v2/social_service_v2.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,52 @@ package decentraland.social_service.v2;
import "google/protobuf/empty.proto";

// Errors

message InvalidFriendshipAction {}

message InternalServerError {}

// Types

message User { string address = 1; }

message RequestResponse {
User user = 1;
int64 created_at = 2;
optional string message = 3;
message Pagination {
int32 limit = 1;
int32 offset = 2;
}

message RequestPayload {
message FriendshipRequestResponse {
User user = 1;
int64 created_at = 2;
optional string message = 3;
}

message Requests {
repeated RequestResponse requests = 1;
message FriendshipRequests {
repeated FriendshipRequestResponse requests = 1;
}

message AcceptResponse { User user = 1; }

message AcceptPayload { User user = 1; }

message RejectResponse { User user = 1; }

message RejectPayload { User user = 1; }

message DeleteResponse { User user = 1; }

message DeletePayload { User user = 1; }
enum ConnectivityStatus {
ONLINE = 0;
OFFLINE = 1;
AWAY = 2;
}

message CancelResponse { User user = 1; }
message GetFriendsPayload {
optional Pagination pagination = 1;
optional ConnectivityStatus status = 2;
}

message CancelPayload { User user = 1; }
message GetFriendshipRequestsPayload {
optional Pagination pagination = 1;
}

message UpsertFriendshipPayload {
message RequestPayload {
User user = 1;
optional string message = 3;
}
message AcceptPayload { User user = 1; }
message RejectPayload { User user = 1; }
message DeletePayload { User user = 1; }
message CancelPayload { User user = 1; }

oneof action {
RequestPayload request = 1;
AcceptPayload accept = 2;
Expand All @@ -54,23 +59,34 @@ message UpsertFriendshipPayload {
}
}

message MutualFriendsPayload {
message GetMutualFriendsPayload {
User user = 1;
optional Pagination pagination = 2;
}

message UsersResponse {
message PaginatedResponse {
int32 total = 1;
int32 page = 2;
}

message PaginatedUsersResponse {
repeated User users = 1;
PaginatedResponse pagination_data = 2;
}

message FriendshipRequestsResponse {
message PaginatedFriendshipRequestsResponse {
oneof response {
Requests requests = 1;
FriendshipRequests requests = 1;
InternalServerError internal_server_error = 2;
}
optional PaginatedResponse pagination_data = 3;
}

message UpsertFriendshipResponse {
message Accepted {}
message Accepted {
string id = 1;
int64 created_at = 2;
}
oneof response {
Accepted accepted = 1;
InvalidFriendshipAction invalid_friendship_action = 2;
Expand All @@ -79,28 +95,57 @@ message UpsertFriendshipResponse {
}

message FriendshipUpdate {
message AcceptResponse { User user = 1; }
message RejectResponse { User user = 1; }
message DeleteResponse { User user = 1; }
message CancelResponse { User user = 1; }

oneof update {
RequestResponse request = 1;
FriendshipRequestResponse request = 1;
AcceptResponse accept = 2;
RejectResponse reject = 4;
DeleteResponse delete = 5;
CancelResponse cancel = 6;
RejectResponse reject = 3;
DeleteResponse delete = 4;
CancelResponse cancel = 5;
}
}

message GetFriendshipStatusPayload {
User user = 1;
}

enum FriendshipStatus {
REQUEST_SENT = 0;
REQUEST_RECEIVED = 1;
CANCELED = 2;
ACCEPTED = 3;
REJECTED = 4;
DELETED = 5;
BLOCKED = 6;
}

message GetFriendshipStatusResponse {
message Ok {
FriendshipStatus status = 1;
optional string message = 2;
}
oneof response {
Ok accepted = 1;
InternalServerError internal_server_error = 2;
}
}

// @deprecated, used for initial migration without Matrix
service SocialService {
// Get the list of friends for the authenticated user
rpc GetFriends(google.protobuf.Empty) returns (stream UsersResponse) {}
rpc GetFriends(GetFriendsPayload) returns (PaginatedUsersResponse) {}

// Get the list of mutual friends between the authenticated user and the one in the parameter
rpc GetMutualFriends(MutualFriendsPayload) returns (stream UsersResponse) {}
rpc GetMutualFriends(GetMutualFriendsPayload) returns (PaginatedUsersResponse) {}

// Get the pending friendship requests for the authenticated user
rpc GetPendingFriendshipRequests(google.protobuf.Empty) returns (FriendshipRequestsResponse) {}
rpc GetPendingFriendshipRequests(GetFriendshipRequestsPayload) returns (PaginatedFriendshipRequestsResponse) {}

// Get the sent friendship requests for the authenticated user
rpc GetSentFriendshipRequests(google.protobuf.Empty) returns (FriendshipRequestsResponse) {}
rpc GetSentFriendshipRequests(GetFriendshipRequestsPayload) returns (PaginatedFriendshipRequestsResponse) {}

// Create or update friendship status: REQUEST, ACCEPT, REJECT, CANCEL, DELETE
rpc UpsertFriendship(UpsertFriendshipPayload)
Expand All @@ -109,4 +154,6 @@ service SocialService {
// Subscribe to updates of friendship status: REQUEST, ACCEPT, REJECT, CANCEL, DELETE
rpc SubscribeToFriendshipUpdates(google.protobuf.Empty)
returns (stream FriendshipUpdate) {}

rpc GetFriendshipStatus(GetFriendshipStatusPayload) returns (GetFriendshipStatusResponse) {}
}
Loading
Loading