|
| 1 | +syntax = "proto3"; |
| 2 | +package decentraland.social_service.v2; |
| 3 | + |
| 4 | +import "google/protobuf/empty.proto"; |
| 5 | + |
| 6 | +// Errors |
| 7 | +message InvalidFriendshipAction {} |
| 8 | +message InternalServerError {} |
| 9 | + |
| 10 | +// Types |
| 11 | +message User { string address = 1; } |
| 12 | + |
| 13 | +message Pagination { |
| 14 | + int32 limit = 1; |
| 15 | + int32 offset = 2; |
| 16 | +} |
| 17 | + |
| 18 | +message FriendshipRequestResponse { |
| 19 | + User user = 1; |
| 20 | + int64 created_at = 2; |
| 21 | + optional string message = 3; |
| 22 | +} |
| 23 | + |
| 24 | +message FriendshipRequests { |
| 25 | + repeated FriendshipRequestResponse requests = 1; |
| 26 | +} |
| 27 | + |
| 28 | +enum ConnectivityStatus { |
| 29 | + ONLINE = 0; |
| 30 | + OFFLINE = 1; |
| 31 | + AWAY = 2; |
| 32 | +} |
| 33 | + |
| 34 | +message GetFriendsPayload { |
| 35 | + optional Pagination pagination = 1; |
| 36 | + optional ConnectivityStatus status = 2; |
| 37 | +} |
| 38 | + |
| 39 | +message GetFriendshipRequestsPayload { |
| 40 | + optional Pagination pagination = 1; |
| 41 | +} |
| 42 | + |
| 43 | +message UpsertFriendshipPayload { |
| 44 | + message RequestPayload { |
| 45 | + User user = 1; |
| 46 | + optional string message = 3; |
| 47 | + } |
| 48 | + message AcceptPayload { User user = 1; } |
| 49 | + message RejectPayload { User user = 1; } |
| 50 | + message DeletePayload { User user = 1; } |
| 51 | + message CancelPayload { User user = 1; } |
| 52 | + |
| 53 | + oneof action { |
| 54 | + RequestPayload request = 1; |
| 55 | + AcceptPayload accept = 2; |
| 56 | + RejectPayload reject = 4; |
| 57 | + DeletePayload delete = 5; |
| 58 | + CancelPayload cancel = 6; |
| 59 | + } |
| 60 | +} |
| 61 | + |
| 62 | +message GetMutualFriendsPayload { |
| 63 | + User user = 1; |
| 64 | + optional Pagination pagination = 2; |
| 65 | +} |
| 66 | + |
| 67 | +message PaginatedResponse { |
| 68 | + int32 total = 1; |
| 69 | + int32 page = 2; |
| 70 | +} |
| 71 | + |
| 72 | +message PaginatedUsersResponse { |
| 73 | + repeated User users = 1; |
| 74 | + PaginatedResponse pagination_data = 2; |
| 75 | +} |
| 76 | + |
| 77 | +message PaginatedFriendshipRequestsResponse { |
| 78 | + oneof response { |
| 79 | + FriendshipRequests requests = 1; |
| 80 | + InternalServerError internal_server_error = 2; |
| 81 | + } |
| 82 | + optional PaginatedResponse pagination_data = 3; |
| 83 | +} |
| 84 | + |
| 85 | +message UpsertFriendshipResponse { |
| 86 | + message Accepted { |
| 87 | + string id = 1; |
| 88 | + int64 created_at = 2; |
| 89 | + } |
| 90 | + oneof response { |
| 91 | + Accepted accepted = 1; |
| 92 | + InvalidFriendshipAction invalid_friendship_action = 2; |
| 93 | + InternalServerError internal_server_error = 3; |
| 94 | + } |
| 95 | +} |
| 96 | + |
| 97 | +message FriendshipUpdate { |
| 98 | + message AcceptResponse { User user = 1; } |
| 99 | + message RejectResponse { User user = 1; } |
| 100 | + message DeleteResponse { User user = 1; } |
| 101 | + message CancelResponse { User user = 1; } |
| 102 | + |
| 103 | + oneof update { |
| 104 | + FriendshipRequestResponse request = 1; |
| 105 | + AcceptResponse accept = 2; |
| 106 | + RejectResponse reject = 3; |
| 107 | + DeleteResponse delete = 4; |
| 108 | + CancelResponse cancel = 5; |
| 109 | + } |
| 110 | +} |
| 111 | + |
| 112 | +message GetFriendshipStatusPayload { |
| 113 | + User user = 1; |
| 114 | +} |
| 115 | + |
| 116 | +enum FriendshipStatus { |
| 117 | + REQUEST_SENT = 0; |
| 118 | + REQUEST_RECEIVED = 1; |
| 119 | + CANCELED = 2; |
| 120 | + ACCEPTED = 3; |
| 121 | + REJECTED = 4; |
| 122 | + DELETED = 5; |
| 123 | + BLOCKED = 6; |
| 124 | +} |
| 125 | + |
| 126 | +message GetFriendshipStatusResponse { |
| 127 | + message Ok { |
| 128 | + FriendshipStatus status = 1; |
| 129 | + optional string message = 2; |
| 130 | + } |
| 131 | + oneof response { |
| 132 | + Ok accepted = 1; |
| 133 | + InternalServerError internal_server_error = 2; |
| 134 | + } |
| 135 | +} |
| 136 | + |
| 137 | +service SocialService { |
| 138 | + // Get the list of friends for the authenticated user |
| 139 | + rpc GetFriends(GetFriendsPayload) returns (PaginatedUsersResponse) {} |
| 140 | + |
| 141 | + // Get the list of mutual friends between the authenticated user and the one in the parameter |
| 142 | + rpc GetMutualFriends(GetMutualFriendsPayload) returns (PaginatedUsersResponse) {} |
| 143 | + |
| 144 | + // Get the pending friendship requests for the authenticated user |
| 145 | + rpc GetPendingFriendshipRequests(GetFriendshipRequestsPayload) returns (PaginatedFriendshipRequestsResponse) {} |
| 146 | + |
| 147 | + // Get the sent friendship requests for the authenticated user |
| 148 | + rpc GetSentFriendshipRequests(GetFriendshipRequestsPayload) returns (PaginatedFriendshipRequestsResponse) {} |
| 149 | + |
| 150 | + // Create or update friendship status: REQUEST, ACCEPT, REJECT, CANCEL, DELETE |
| 151 | + rpc UpsertFriendship(UpsertFriendshipPayload) |
| 152 | + returns (UpsertFriendshipResponse) {} |
| 153 | + |
| 154 | + // Subscribe to updates of friendship status: REQUEST, ACCEPT, REJECT, CANCEL, DELETE |
| 155 | + rpc SubscribeToFriendshipUpdates(google.protobuf.Empty) |
| 156 | + returns (stream FriendshipUpdate) {} |
| 157 | + |
| 158 | + rpc GetFriendshipStatus(GetFriendshipStatusPayload) returns (GetFriendshipStatusResponse) {} |
| 159 | +} |
0 commit comments