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
uid
andprofileID
are not the same value [403]. - Fetches the profile for the record with a
uid
corresponding to theuid
passed (receptor
) [404]. - Fetches the profile for the record with a
uid
corresponding to theprofileID
passed (sender
) [404]. - Ensure that neither
uid
is found insender
’sblocked
field nor thatprofileID
is found inreceptor
’sblocked
field [403]. - Ensure that
profileID
is inreceptor
’sreceived_follow_requests
field [403]. - If
receptor
’saccount_type
is set toprivate
orrestricted
, do the following:- Remove
profileID
fromreceptor
’sreceived_follow_requests
. - Remove
uid
fromsender
’ssent_follow_requests
. - Append
profileID
inreceptor
’sfollowers
ifaccept
is equal totrue
. - Append
uid
insender
’sfollowing
ifaccept
is equal totrue
.
- Remove
- Do the same thing as above if
receptor
’saccount_type
is set toghost
and it it hasprofileID
as value among itsfollowing
field [403]. - Generates a new
notificationID
and atimestamp
corresponding to the current date and time, and creates a new object in thenotifications
collection with the following data ifaccept
is 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}` }