mirror of
				https://gitlab.com/comunic/comunicapiv2
				synced 2025-11-03 11:04:02 +00:00 
			
		
		
		
	Can get the list of post targets of a user
This commit is contained in:
		@@ -44,6 +44,25 @@ export class FriendsHelper {
 | 
			
		||||
		return results.map((r) => this.DbToFriend(r));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Get the list of friends of a given user who allows
 | 
			
		||||
	 * him to create post on their pages
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param userID ID of the user making the request
 | 
			
		||||
	 */
 | 
			
		||||
	public static async GetListThatAllowsPostsFromUser(userID: number) : Promise<Array<number>> {
 | 
			
		||||
		const list = await DatabaseHelper.Query({
 | 
			
		||||
			table: FRIENDS_TABLE,
 | 
			
		||||
			where: {
 | 
			
		||||
				autoriser_post_page: 1,
 | 
			
		||||
				ID_amis: userID
 | 
			
		||||
			},
 | 
			
		||||
			fields: ["ID_personne as user_id"]
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		return list.map((e) => e.user_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Get information about a single membership
 | 
			
		||||
	 * 
 | 
			
		||||
 
 | 
			
		||||
@@ -83,6 +83,46 @@ export class GroupsHelper {
 | 
			
		||||
		return list.map(e => e.groups_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Get the list of gruops of a user where the users can create
 | 
			
		||||
	 * posts
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param userID The ID of the target user
 | 
			
		||||
	 */
 | 
			
		||||
	public static async GetListUserWhereCanCreatePosts(userID: number) : Promise<Array<number>> {
 | 
			
		||||
		const list = await DatabaseHelper.Query({
 | 
			
		||||
			// Members table
 | 
			
		||||
			table: GROUPS_MEMBERS_TABLE,
 | 
			
		||||
			tableAlias: "m",
 | 
			
		||||
 | 
			
		||||
			// Groups liist table
 | 
			
		||||
			joins: [
 | 
			
		||||
				{
 | 
			
		||||
					table: GROUPS_LIST_TABLE,
 | 
			
		||||
					tableAlias: "g",
 | 
			
		||||
					condition: "m.groups_id = g.id"
 | 
			
		||||
				}
 | 
			
		||||
			],
 | 
			
		||||
 | 
			
		||||
			where: {
 | 
			
		||||
				user_id: userID
 | 
			
		||||
			},
 | 
			
		||||
 | 
			
		||||
			customWhere: "level = ? OR level = ? OR (level = ? AND posts_level = ?)",
 | 
			
		||||
			customWhereArgs: [
 | 
			
		||||
				GroupMembershipLevels.ADMINISTRATOR.toString(),
 | 
			
		||||
				GroupMembershipLevels.MODERATOR.toString(),
 | 
			
		||||
 | 
			
		||||
				GroupMembershipLevels.MEMBER.toString(),
 | 
			
		||||
				GroupPostsCreationLevel.POSTS_LEVEL_ALL_MEMBERS.toString()
 | 
			
		||||
			],
 | 
			
		||||
 | 
			
		||||
			fields: ["g.id"]
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		return list.map((e) => e.id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Get information about a group
 | 
			
		||||
	 * 
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user