mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-25 23:09:22 +00:00
Can delete the posts that uses a given movie
This commit is contained in:
parent
df2d2b66be
commit
77bb8a6ae1
@ -9,6 +9,7 @@ import { LikesHelper, LikesType } from "./LikesHelper";
|
|||||||
import { CommentsHelper } from "./CommentsHelper";
|
import { CommentsHelper } from "./CommentsHelper";
|
||||||
import { existsSync, unlinkSync } from "fs";
|
import { existsSync, unlinkSync } from "fs";
|
||||||
import { SurveyHelper } from "./SurveyHelper";
|
import { SurveyHelper } from "./SurveyHelper";
|
||||||
|
import { Movie } from "../entities/Movie";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Posts helper
|
* Posts helper
|
||||||
@ -374,6 +375,30 @@ export class PostsHelper {
|
|||||||
return list.map((l) => this.DBToPost(l));
|
return list.map((l) => this.DBToPost(l));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of posts that uses a certain movie
|
||||||
|
*
|
||||||
|
* @param movie Information about the target movie
|
||||||
|
*/
|
||||||
|
private static async GetPostsForMovie(movie: Movie) : Promise<Post[]> {
|
||||||
|
return (await DatabaseHelper.Query({
|
||||||
|
table: TABLE_NAME,
|
||||||
|
where: {
|
||||||
|
idvideo: movie.id
|
||||||
|
}
|
||||||
|
})).map(this.DBToPost)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all the posts that includes a given movie
|
||||||
|
*
|
||||||
|
* @param movie Information about the target movie
|
||||||
|
*/
|
||||||
|
public static async DeleteAllWithMovie(movie: Movie) {
|
||||||
|
for(const post of await this.GetPostsForMovie(movie))
|
||||||
|
await this.Delete(post.id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete all the posts of a given user
|
* Delete all the posts of a given user
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user