-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsocial.proto
152 lines (121 loc) · 3.72 KB
/
social.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
syntax = "proto3";
import "commons.proto";
option java_multiple_files = true;
option java_package = "com.kotlang.social";
option java_outer_classname = "SocialInternal";
option go_package = "github.com/Kotlang/socialGo/generated";
package social;
service UserPost {
//create new post or reply to a post or add answer to a post
rpc CreatePost(UserPostRequest) returns (UserPostProto) {}
rpc DeletePost(DeletePostRequest) returns (SocialStatusResponse) {}
rpc GetFeed(GetFeedRequest) returns (FeedResponse) {}
rpc GetMediaUploadUrl(MediaUploadRequest) returns (MediaUploadURL) {}
// Returns post with it's text, media, webPreviews, tags, etc.
rpc GetPost(GetPostRequest) returns (UserPostProto) {}
rpc GetBookmarks(GetBookmarksRequest) returns (FeedResponse) {}
rpc GetTags(GetTagsRequest) returns (TagListResponse) {}
// directly takes input of post image or video and uploads the media.
rpc UploadPostMedia(stream UploadPostMediaRequest) returns (UploadPostMediaResponse) {}
// Called from frontend before CreatePost.
// Will be usually called whenever a user pastes a link in post - To show preview as user is creating post.
// Also, before createPost - Idempotency.
rpc ParsePost(UserPostRequest) returns (UserPostRequest) {}
}
enum PostType {
FEED_POST = 0;
QnA_QUESTION = 1;
QnA_ANSWER = 2;
}
message UserPostRequest {
//can be markup like html containing images
//Question markup in case of QnA_QUESTION
//Answer markup in case of QnA_ANSWER
//Just markup in case FEED_POST
string post = 1;
repeated string tags = 2;
//in case of QnA_ANSWER use this field to refer to questionId
string title = 4;
// List of media urls uploaded via UploadPostMedia API.
repeated MediaUrl mediaUrls = 5;
// Populated by backend by parsing the webpage urls in post = 1;
repeated WebPreview webPreviews = 7;
// For answer on a post use postType as QnA_ANSWER.
PostType postType = 6;
repeated string contentType = 8;
}
message UserPostProto {
string post = 1;
repeated string tags = 2;
string postId = 3;
repeated MediaUrl mediaUrls = 4;
repeated WebPreview webPreviews = 16;
int64 createdOn = 5;
string userId = 7;
SocialProfile authorInfo = 13;
map<string, int64> numReacts = 8;
int32 numReplies = 9;
int32 numShares = 10;
string title = 11;
repeated string feedUserReactions = 12;
repeated string contentType = 17;
}
message DeletePostRequest {
string id = 1;
}
message FeedFilters {
string tag = 1;
string userId = 2;
string createdBy = 3;
PostType postType = 4;
repeated string contentType = 5;
repeated string type = 6;
bool fetchUserCommentedPosts = 7;
bool fetchUserReactedPosts = 8;
}
message GetFeedRequest{
FeedFilters filters = 1;
string referencePost = 2;
//pagination
//pageNumber starting from 0
int32 pageSize = 3;
int32 pageNumber = 4;
}
message FeedResponse{
repeated UserPostProto posts = 1;
int32 pageNumber = 2;
int32 pageSize = 3;
int32 totalPages = 4;
}
message MediaUploadRequest {
// jpg or png or mp4
string mediaExtension = 1;
}
message GetPostRequest {
string postId = 1;
}
message GetBookmarksRequest {
//pagination
//pageNumber starting from 0
int32 pageSize = 3;
int32 pageNumber = 4;
}
message GetTagsRequest {}
message Tag {
string Tag = 1;
string TagDescription = 2;
int32 NumPosts = 3;
}
message TagListResponse {
repeated Tag tags = 1;
}
message MediaUploadURL {
string uploadUrl = 1;
string mediaUrl = 2;
}
message UploadPostMediaRequest {
bytes chunkData = 1;
}
message UploadPostMediaResponse {
string uploadPath = 1;
}