mirror of
				https://gitlab.com/comunic/comunicapiv2
				synced 2025-11-04 03:24:04 +00:00 
			
		
		
		
	Get information about a single friendship
This commit is contained in:
		@@ -42,6 +42,44 @@ export class FriendsHelper {
 | 
			
		||||
		return results.map((r) => this.DbToFriend(r));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Get information about a single membership
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param userID Target user ID (ID of the user making the request)
 | 
			
		||||
	 * @param friendID Target friend ID
 | 
			
		||||
	 * @returns Information about the membership / null if no membership was found
 | 
			
		||||
	 */
 | 
			
		||||
	public static async GetSingleInfo(userID: number, friendID: number) : Promise<Friend> {
 | 
			
		||||
		
 | 
			
		||||
		// Same request has above, but just for a single user
 | 
			
		||||
		const result = await DatabaseHelper.QueryRow({
 | 
			
		||||
			table: FRIENDS_TABLE + " f",
 | 
			
		||||
			where: {
 | 
			
		||||
				ID_personne: userID,
 | 
			
		||||
				ID_amis: friendID
 | 
			
		||||
			},
 | 
			
		||||
			joins: [
 | 
			
		||||
				{
 | 
			
		||||
					table: USER_TABLE + " u",
 | 
			
		||||
					condition: "f.ID_amis = u.ID"
 | 
			
		||||
				}
 | 
			
		||||
			],
 | 
			
		||||
			fields: [
 | 
			
		||||
				"u.last_activity",
 | 
			
		||||
				"f.ID_amis",
 | 
			
		||||
				"f.actif",
 | 
			
		||||
				"f.abonnement",
 | 
			
		||||
				"f.autoriser_post_page"
 | 
			
		||||
			],
 | 
			
		||||
			order: "u.last_activity DESC"
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		if(result == null)
 | 
			
		||||
			return null;
 | 
			
		||||
 | 
			
		||||
		return this.DbToFriend(result);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Count the number of friendship requests a user
 | 
			
		||||
	 * received
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user