mirror of
				https://gitlab.com/comunic/comunicapiv2
				synced 2025-11-04 03:24:04 +00:00 
			
		
		
		
	Can create a private conversation
This commit is contained in:
		@@ -342,6 +342,35 @@ export class ConversationsHelper {
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Search for private conversations between two users
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param user1 The first user
 | 
			
		||||
	 * @param user2 The second user
 | 
			
		||||
	 * @returns The entire list of found conversations
 | 
			
		||||
	 */
 | 
			
		||||
	public static async FindPrivate(user1: number, user2: number) : Promise<Array<number>> {
 | 
			
		||||
		const result = await DatabaseHelper.Query({
 | 
			
		||||
			table: USERS_TABLE,
 | 
			
		||||
			tableAlias: "t1",
 | 
			
		||||
			joins: [
 | 
			
		||||
				{
 | 
			
		||||
					table: USERS_TABLE,
 | 
			
		||||
					tableAlias: "t2",
 | 
			
		||||
					condition: "t1.conv_id = t2.conv_id"
 | 
			
		||||
				}
 | 
			
		||||
			],
 | 
			
		||||
			where: {
 | 
			
		||||
				"t1.user_id": user1,
 | 
			
		||||
				"t2.user_id": user2
 | 
			
		||||
			},
 | 
			
		||||
			customWhere: "(SELECT COUNT(*) FROM " + USERS_TABLE + " WHERE conv_id = t1.conv_id) = 2",
 | 
			
		||||
			fields: ["t1.conv_id AS conv_id"]
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		return result.map(r => r.conv_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Get the list of members of a conversation
 | 
			
		||||
	 * 
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user