1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-20 16:45:16 +00:00

Can get the list of post targets of a user

This commit is contained in:
2020-03-21 09:15:21 +01:00
parent 8c09848ee9
commit d362c0faab
4 changed files with 77 additions and 0 deletions

View File

@ -18,6 +18,7 @@ import { pathUserData } from "../utils/UserDataUtils";
import { statSync } from "fs";
import { lookup } from "mime-types";
import { NewSurvey } from "../entities/NewSurvey";
import { FriendsHelper } from "../helpers/FriendsHelper";
/**
* Posts controller
@ -349,6 +350,21 @@ export class PostsController {
h.success();
}
/**
* Get the lists of targets where the current user can create posts
*
* @param h Request handler
*/
public static async GetTargets(h: RequestHandler) {
const friends = await FriendsHelper.GetListThatAllowsPostsFromUser(h.getUserId());
const groups = await GroupsHelper.GetListUserWhereCanCreatePosts(h.getUserId());
h.send({
friends: friends,
groups: groups
});
}
/**
* Send multiple posts to the API
*

View File

@ -200,6 +200,8 @@ export const Routes : Route[] = [
{path: "/posts/delete", cb: (h) => PostsController.DeletePost(h)},
{path: "/posts/getAvailableTargets", cb: (h) => PostsController.GetTargets(h)},
// Notifications controller