Skip to content
Snippets Groups Projects
Commit ec085b2f authored by Matt Kirby's avatar Matt Kirby
Browse files

Merge branch 'friend-service' of...

Merge branch 'friend-service' of https://gitlab.surrey.ac.uk/com3014-coursework/daily-thought-app into friend-service
parents 98342bb9 cf187309
No related branches found
No related tags found
1 merge request!15Add Friend service
...@@ -22,6 +22,10 @@ export class RequestManager { ...@@ -22,6 +22,10 @@ export class RequestManager {
* @returns * @returns
*/ */
public NewRequest = async (sourceId: string, targetId: string):Promise<FriendRequest> => { 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){ if(await RequestDataStore.GetItem({SourceUser: sourceId, TargetUser: targetId}) !== null || await RequestDataStore.GetItem({SourceUser: targetId, TargetUser: sourceId}) !== null){
throw new Error("Request already exists!"); 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