GNW YES!
- Conversation A conversation is a collection of a group of participants who wants to send messages to each other. + conversationId: globally unique identifier for each conversation + participants: all users that can talk and receive message in this conversation
- Message Server A server instance that handles user's websocket connection.
- Conversation Server A server that provides conversations, act like a in memory database, conversation persistence and do query over conversations.
- @POST
url/signup - req:
username,password,email,display_name,birthday. - res: (char_id to db),
200/4XX/5XX
- @POST
url/login - req:
username,password - res:
200/4XX/5XX,JWT_token
- @POST
url/send-passcode - req:
username - res (RPC call to communication service),
200/4XX/5XX
- @POST
url/change-password - req:
username,passcode,opaque_token,new_password - res:
200/4XX/5XX(depends on whether the req carries opaque token or not)
- @POST
url/check-authorization - req:
username,opaque_token - res:
200/4XX/5XX
- Everytime the client sends a
opaque_token, the API Gateway would translate theopaque_tokentoJWT_token. What the customs service gets is aJWT_token. - Everytime the custom service response with a
JWT_token, the API Gateway would map theJWT_tokentoopaque_token. What the client gets is aopaque_token. - To ensure that the
opaque_tokenwill not be stolen, the API Gateway must response theopaque_tokenin the Set-Cookie header with the Secure attribute and the HttpOnly attribute.
- @POST
url/getContacts - req: jwt, (username)
- res:
200/ others - payload:
// alphabetically ordered
[
{username: "mantinglin", displayName: "Tinglin Man", chatID: "gnw_id_10086"},
{username: "luoxiaolei", displayName: "Xiaolei Luo", chatID: "gnw_id_10010"},
]- @POST
url/getIncomingFriendRequests - req: jwt, (username)
- res:
200/ others - payload:
// chronologically ordered
[
{username: "mantinglin", displayName: "Tinglin Man", chatID: "gnw_id_10086"},
{username: "luoxiaolei", displayName: "Xiaolei Luo", chatID: "gnw_id_10010"},
]- @POST
url/getPendingFriendRequests - req: jwt, (username)
- res:
200/ others - payload:
// chronologically ordered
[
{username: "mantinglin", displayName: "Tinglin Man", chatID: "gnw_id_10086"},
{username: "luoxiaolei", displayName: "Xiaolei Luo", chatID: "gnw_id_10010"},
]- @POST
url/addFriend - req: jwt, friend_username, (username)
- res:
200/ others
- @POST
url/unfriend - req: jwt, friend_username, (username)
- res:
200/ others
- @POST
url/inviteFriends - req: jwt, friend_email, (username)
- res:
200/ others
upon friend is added, the server should generate the conversationId and associate it with the contact
- @GET
url/pending - req: jwt
- res: All pending friend requests and potential result(approved/denied, conversationId)
create table user (
uuid int not null auto_increment,
username varchar(255) not null,
display_name varchar(255) not null,
email varchar(255) not null,
primary key (uuid),
unique (username)
);
create table auth (
uuid int not null,
hashed_password varchar(255) not null,
primary key (uuid)
);
create table contact (
id int not null auto_increment,
uuid_a int not null,
uuid_b int not null,
primary key (id)
);
create table friend_request (
id int not null auto_increment,
uuid_a int not null,
uuid_b int not null,
primary key (id)
);
create table p2p_chat (
chat_id varchar(255) not null,
uuid_a int not null,
uuid_b int not null,
primary key (chat_id)
);
create table p2g_chat (
chat_id varchar(255) not null,
uuid int not null,
);