mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 13:29:22 +00:00
Delete all posts likes
This commit is contained in:
parent
e67fe26652
commit
66c545fc3d
@ -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]
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user