mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 05:19:22 +00:00
Can set for friends if they can create posts or not
This commit is contained in:
parent
4cfb85d1ad
commit
bb47968626
@ -181,6 +181,20 @@ export class FriendsController {
|
||||
h.success("Following status upated!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update post text authorization status
|
||||
*
|
||||
* @param h Request handler
|
||||
*/
|
||||
public static async SetCanPostTexts(h: RequestHandler) {
|
||||
const friendID = await h.postFriendId("friendID");
|
||||
const allow = h.postBool("allow");
|
||||
|
||||
await FriendsHelper.SetCanPostTexts(h.getUserId(), friendID, allow);
|
||||
|
||||
h.success("Updated status!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn a friend object into an API entry
|
||||
*
|
||||
|
@ -93,6 +93,8 @@ export const Routes : Route[] = [
|
||||
|
||||
{path: "/friends/setFollowing", cb: (h) => FriendsController.SetFollowing(h)},
|
||||
|
||||
{path: "/friends/set_can_post_texts", cb: (h) => FriendsController.SetCanPostTexts(h)},
|
||||
|
||||
|
||||
// Conversations controller
|
||||
{path: "/conversations/create", cb: (h) => ConversationsController.CreateConversation(h)},
|
||||
|
@ -265,6 +265,26 @@ export class FriendsHelper {
|
||||
}) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the post creation authorization status
|
||||
*
|
||||
* @param userID The ID of the user updating the authorization status
|
||||
* @param friendID The ID of the target friend
|
||||
* @param allow New authorization status
|
||||
*/
|
||||
public static async SetCanPostTexts(userID: number, friendID: number, allow: boolean) {
|
||||
await DatabaseHelper.UpdateRows({
|
||||
table: FRIENDS_TABLE,
|
||||
where: {
|
||||
ID_personne: userID,
|
||||
ID_amis: friendID
|
||||
},
|
||||
set: {
|
||||
autoriser_post_page: allow ? 1 : 0
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check out whether friendship allows to create posts or not
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user