1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-22 21:39:22 +00:00

Delete all posts likes

This commit is contained in:
Pierre HUBERT 2020-03-20 18:59:35 +01:00
parent e67fe26652
commit 66c545fc3d
2 changed files with 17 additions and 0 deletions

View File

@ -69,4 +69,17 @@ export class LikesHelper {
} }
}) == 1; }) == 1;
} }
/**
* Delete all the likes related to an element
*
* @param id Target element ID
* @param type The type of target element
*/
public static async DeleteAll(id: number, type: LikesType) {
await DatabaseHelper.DeleteRows(LIKES_TABLE, {
ID_type: id,
type: LikesKindsDB[type]
});
}
} }

View File

@ -5,6 +5,7 @@ import { UserHelper } from "./UserHelper";
import { GroupsHelper } from "./GroupsHelper"; import { GroupsHelper } from "./GroupsHelper";
import { GroupMembershipLevels } from "../entities/GroupMember"; import { GroupMembershipLevels } from "../entities/GroupMember";
import { mysql_date } from "../utils/DateUtils"; import { mysql_date } from "../utils/DateUtils";
import { LikesHelper, LikesType } from "./LikesHelper";
/** /**
* Posts helper * Posts helper
@ -483,7 +484,10 @@ export class PostsHelper {
* @param postID The ID of the post to delete * @param postID The ID of the post to delete
*/ */
public static async Delete(postID: number) { public static async Delete(postID: number) {
const post = await this.GetSingle(postID);
// Delete all the likes associated with the post
await LikesHelper.DeleteAll(postID, LikesType.POST);
} }
/** /**