Request
/api/v2/profile/request
Post
profiles
notifications
jwt
Purpose
To allow a user to accept or decline a follow request.
Body Content [input]
{
uid: string,
profileID: string,
accept: bool
}
Returns if valid [output]
{
message: string,
error: 0
}
What the API does
- Checks that
uidandprofileIDare not the same value [403]. - Fetches the profile for the record with a
uidcorresponding to theuidpassed (receptor) [404]. - Fetches the profile for the record with a
uidcorresponding to theprofileIDpassed (sender) [404]. - Ensure that neither
uidis found insender’sblockedfield nor thatprofileIDis found inreceptor’sblockedfield [403]. - Ensure that
profileIDis inreceptor’sreceived_follow_requestsfield [403]. - If
receptor’saccount_typeis set toprivateorrestricted, do the following:- Remove
profileIDfromreceptor’sreceived_follow_requests. - Remove
uidfromsender’ssent_follow_requests. - Append
profileIDinreceptor’sfollowersifacceptis equal totrue. - Append
uidinsender’sfollowingifacceptis equal totrue.
- Remove
- Do the same thing as above if
receptor’saccount_typeis set toghostand it it hasprofileIDas value among itsfollowingfield [403]. - Generates a new
notificationIDand atimestampcorresponding to the current date and time, and creates a new object in thenotificationscollection with the following data ifacceptis equal totrue:{ uid: profileID, notificationID: notificationID, content: `You are now following uid.${uid}`, profileID: uid, type: "follow_accept", created_on: timestamp, read: false, redirect: `/profile/${uid}` }