Skip to content
Snippets Groups Projects
Commit cf187309 authored by Felipe D'Abrantes's avatar Felipe D'Abrantes
Browse files

Prevent users from friending themselves

parent 1e6ebc60
No related branches found
No related tags found
1 merge request!15Add Friend service
......@@ -22,6 +22,10 @@ export class RequestManager {
* @returns
*/
public NewRequest = async (sourceId: string, targetId: string):Promise<FriendRequest> => {
if(sourceId === targetId){
throw new Error("Sorry, can't friend yourself! :(");
}
if(await RequestDataStore.GetItem({SourceUser: sourceId, TargetUser: targetId}) !== null || await RequestDataStore.GetItem({SourceUser: targetId, TargetUser: sourceId}) !== null){
throw new Error("Request already exists!");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment