mirror of
				https://gitlab.com/comunic/comunicapiv2
				synced 2025-11-04 03:24:04 +00:00 
			
		
		
		
	Export user likes
This commit is contained in:
		@@ -9,6 +9,7 @@ import { GeneralSettings, UserPageStatus, LangSettings, SecuritySettings } from
 | 
			
		||||
import { AccountExport } from "../entities/AccountExport";
 | 
			
		||||
import { PostsHelper } from "./PostsHelper";
 | 
			
		||||
import { CommentsHelper } from "./CommentsHelper";
 | 
			
		||||
import { LikesHelper } from "./LikesHelper";
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Account helper
 | 
			
		||||
@@ -393,7 +394,10 @@ export class AccountHelper {
 | 
			
		||||
			postsList: await PostsHelper.ExportAllPostsUser(userID),
 | 
			
		||||
 | 
			
		||||
			// Export the list of comments
 | 
			
		||||
			comments: await CommentsHelper.ExportAllUser(userID)
 | 
			
		||||
			comments: await CommentsHelper.ExportAllUser(userID),
 | 
			
		||||
 | 
			
		||||
			// Export user likes
 | 
			
		||||
			likes: await LikesHelper.ExportAllUser(userID),
 | 
			
		||||
		})
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
import { DatabaseHelper } from "./DatabaseHelper";
 | 
			
		||||
import { mysql_date } from "../utils/DateUtils";
 | 
			
		||||
import { UserLike } from "../entities/UserLike";
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Likes helper
 | 
			
		||||
@@ -119,4 +120,33 @@ export class LikesHelper {
 | 
			
		||||
			type: LikesKindsDB[type]
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Get all the likes of a user
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param userID Target user ID
 | 
			
		||||
	 */
 | 
			
		||||
	public static async ExportAllUser(userID: number) {
 | 
			
		||||
		return (await DatabaseHelper.Query({
 | 
			
		||||
			table: LIKES_TABLE,
 | 
			
		||||
			where: {
 | 
			
		||||
				ID_personne: userID
 | 
			
		||||
			}
 | 
			
		||||
		})).map(this.DBToUserLike);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Turn a database entry into a like entry
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param row Target database row
 | 
			
		||||
	 */
 | 
			
		||||
	private static DBToUserLike(row: any) : UserLike {
 | 
			
		||||
		return new UserLike({
 | 
			
		||||
			id: row.ID,
 | 
			
		||||
			userID: row.ID_personne,
 | 
			
		||||
			timeSent: new Date(row.Date_envoi).getTime()/1000,
 | 
			
		||||
			elemId: row.ID_type,
 | 
			
		||||
			elemType: row.type
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user