|
@@ -11,68 +11,100 @@ const SongsModule = moduleManager.modules.songs;
|
|
|
const CacheModule = moduleManager.modules.cache;
|
|
|
const ActivitiesModule = moduleManager.modules.activities;
|
|
|
|
|
|
-const reportableIssues = [
|
|
|
- {
|
|
|
- name: "Video",
|
|
|
- reasons: ["Doesn't exist", "It's private", "It's not available in my country"]
|
|
|
- },
|
|
|
- {
|
|
|
- name: "Title",
|
|
|
- reasons: ["Incorrect", "Inappropriate"]
|
|
|
- },
|
|
|
- {
|
|
|
- name: "Duration",
|
|
|
- reasons: ["Skips too soon", "Skips too late", "Starts too soon", "Skips too late"]
|
|
|
- },
|
|
|
- {
|
|
|
- name: "Artists",
|
|
|
- reasons: ["Incorrect", "Inappropriate"]
|
|
|
- },
|
|
|
- {
|
|
|
- name: "Thumbnail",
|
|
|
- reasons: ["Incorrect", "Inappropriate", "Doesn't exist"]
|
|
|
- }
|
|
|
-];
|
|
|
+CacheModule.runJob("SUB", {
|
|
|
+ channel: "report.issue.toggle",
|
|
|
+ cb: data =>
|
|
|
+ WSModule.runJob("EMIT_TO_ROOMS", {
|
|
|
+ rooms: [`edit-song.${data.songId}`, `view-report.${data.reportId}`],
|
|
|
+ args: [
|
|
|
+ "event:admin.report.issue.toggled",
|
|
|
+ { data: { issueId: data.issueId, reportId: data.reportId, resolved: data.resolved } }
|
|
|
+ ]
|
|
|
+ })
|
|
|
+});
|
|
|
|
|
|
CacheModule.runJob("SUB", {
|
|
|
channel: "report.resolve",
|
|
|
- cb: reportId => {
|
|
|
- WSModule.runJob("EMIT_TO_ROOM", {
|
|
|
- room: "admin.reports",
|
|
|
+ cb: ({ reportId, songId }) =>
|
|
|
+ WSModule.runJob("EMIT_TO_ROOMS", {
|
|
|
+ rooms: ["admin.reports", `edit-song.${songId}`, `view-report.${reportId}`],
|
|
|
args: ["event:admin.report.resolved", { data: { reportId } }]
|
|
|
- });
|
|
|
- }
|
|
|
+ })
|
|
|
});
|
|
|
|
|
|
CacheModule.runJob("SUB", {
|
|
|
channel: "report.create",
|
|
|
cb: report => {
|
|
|
- WSModule.runJob("EMIT_TO_ROOM", {
|
|
|
- room: "admin.reports",
|
|
|
- args: ["event:admin.report.created", { data: { report } }]
|
|
|
+ console.log(report);
|
|
|
+
|
|
|
+ DBModule.runJob("GET_MODEL", { modelName: "user" }, this).then(userModel => {
|
|
|
+ userModel
|
|
|
+ .findById(report.createdBy)
|
|
|
+ .select({ avatar: -1, name: -1, username: -1 })
|
|
|
+ .exec((err, { avatar, name, username }) => {
|
|
|
+ report.createdBy = {
|
|
|
+ avatar,
|
|
|
+ name,
|
|
|
+ username,
|
|
|
+ _id: report.createdBy
|
|
|
+ };
|
|
|
+
|
|
|
+ WSModule.runJob("EMIT_TO_ROOMS", {
|
|
|
+ rooms: ["admin.reports", `edit-song.${report.song._id}`],
|
|
|
+ args: ["event:admin.report.created", { data: { report } }]
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
export default {
|
|
|
/**
|
|
|
- * Gets all reports
|
|
|
+ * Gets all reports that haven't been yet resolved
|
|
|
*
|
|
|
* @param {object} session - the session object automatically added by the websocket
|
|
|
* @param {Function} cb - gets called with the result
|
|
|
*/
|
|
|
index: isAdminRequired(async function index(session, cb) {
|
|
|
- const reportModel = await DBModule.runJob(
|
|
|
- "GET_MODEL",
|
|
|
- {
|
|
|
- modelName: "report"
|
|
|
- },
|
|
|
- this
|
|
|
- );
|
|
|
+ const reportModel = await DBModule.runJob("GET_MODEL", { modelName: "report" }, this);
|
|
|
+ const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }, this);
|
|
|
+
|
|
|
async.waterfall(
|
|
|
[
|
|
|
- next => {
|
|
|
- reportModel.find({ resolved: false }).sort({ released: "desc" }).exec(next);
|
|
|
+ next => reportModel.find({ resolved: false }).sort({ createdAt: "desc" }).exec(next),
|
|
|
+ (_reports, next) => {
|
|
|
+ const reports = [];
|
|
|
+
|
|
|
+ async.each(
|
|
|
+ _reports,
|
|
|
+ (report, cb) => {
|
|
|
+ console.log(typeof report.createdBy);
|
|
|
+
|
|
|
+ userModel
|
|
|
+ .findById(report.createdBy)
|
|
|
+ .select({ avatar: -1, name: -1, username: -1 })
|
|
|
+ .exec((err, user) => {
|
|
|
+ if (!user)
|
|
|
+ reports.push({
|
|
|
+ ...report._doc,
|
|
|
+ createdBy: { _id: report.createdBy }
|
|
|
+ });
|
|
|
+ else
|
|
|
+ reports.push({
|
|
|
+ ...report._doc,
|
|
|
+ createdBy: {
|
|
|
+ avatar: user.avatar,
|
|
|
+ name: user.name,
|
|
|
+ username: user.username,
|
|
|
+ _id: report.createdBy
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return cb(err);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ err => next(err, reports)
|
|
|
+ );
|
|
|
}
|
|
|
],
|
|
|
async (err, reports) => {
|
|
@@ -81,6 +113,7 @@ export default {
|
|
|
this.log("ERROR", "REPORTS_INDEX", `Indexing reports failed. "${err}"`);
|
|
|
return cb({ status: "error", message: err });
|
|
|
}
|
|
|
+
|
|
|
this.log("SUCCESS", "REPORTS_INDEX", "Indexing reports successful.");
|
|
|
return cb({ status: "success", data: { reports } });
|
|
|
}
|
|
@@ -95,18 +128,33 @@ export default {
|
|
|
* @param {Function} cb - gets called with the result
|
|
|
*/
|
|
|
findOne: isAdminRequired(async function findOne(session, reportId, cb) {
|
|
|
- const reportModel = await DBModule.runJob(
|
|
|
- "GET_MODEL",
|
|
|
- {
|
|
|
- modelName: "report"
|
|
|
- },
|
|
|
- this
|
|
|
- );
|
|
|
+ const reportModel = await DBModule.runJob("GET_MODEL", { modelName: "report" }, this);
|
|
|
+ const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }, this);
|
|
|
+
|
|
|
async.waterfall(
|
|
|
[
|
|
|
- next => {
|
|
|
- reportModel.findOne({ _id: reportId }).exec(next);
|
|
|
- }
|
|
|
+ next => reportModel.findOne({ _id: reportId }).exec(next),
|
|
|
+ (report, next) =>
|
|
|
+ userModel
|
|
|
+ .findById(report.createdBy)
|
|
|
+ .select({ avatar: -1, name: -1, username: -1 })
|
|
|
+ .exec((err, user) => {
|
|
|
+ if (!user)
|
|
|
+ next(err, {
|
|
|
+ ...report._doc,
|
|
|
+ createdBy: { _id: report.createdBy }
|
|
|
+ });
|
|
|
+ else
|
|
|
+ next(err, {
|
|
|
+ ...report._doc,
|
|
|
+ createdBy: {
|
|
|
+ avatar: user.avatar,
|
|
|
+ name: user.name,
|
|
|
+ username: user.username,
|
|
|
+ _id: report.createdBy
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
],
|
|
|
async (err, report) => {
|
|
|
if (err) {
|
|
@@ -114,6 +162,7 @@ export default {
|
|
|
this.log("ERROR", "REPORTS_FIND_ONE", `Finding report "${reportId}" failed. "${err}"`);
|
|
|
return cb({ status: "error", message: err });
|
|
|
}
|
|
|
+
|
|
|
this.log("SUCCESS", "REPORTS_FIND_ONE", `Finding report "${reportId}" successful.`);
|
|
|
return cb({ status: "success", data: { report } });
|
|
|
}
|
|
@@ -128,28 +177,45 @@ export default {
|
|
|
* @param {Function} cb - gets called with the result
|
|
|
*/
|
|
|
getReportsForSong: isAdminRequired(async function getReportsForSong(session, songId, cb) {
|
|
|
- const reportModel = await DBModule.runJob(
|
|
|
- "GET_MODEL",
|
|
|
- {
|
|
|
- modelName: "report"
|
|
|
- },
|
|
|
- this
|
|
|
- );
|
|
|
+ const reportModel = await DBModule.runJob("GET_MODEL", { modelName: "report" }, this);
|
|
|
+ const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }, this);
|
|
|
+
|
|
|
async.waterfall(
|
|
|
[
|
|
|
- next => {
|
|
|
- reportModel
|
|
|
- .find({ song: { _id: songId }, resolved: false })
|
|
|
- .sort({ released: "desc" })
|
|
|
- .exec(next);
|
|
|
- },
|
|
|
+ next =>
|
|
|
+ reportModel.find({ "song._id": songId, resolved: false }).sort({ createdAt: "desc" }).exec(next),
|
|
|
|
|
|
(_reports, next) => {
|
|
|
const reports = [];
|
|
|
- for (let i = 0; i < _reports.length; i += 1) {
|
|
|
- data.push(_reports[i]._id);
|
|
|
- }
|
|
|
- next(null, reports);
|
|
|
+
|
|
|
+ async.each(
|
|
|
+ _reports,
|
|
|
+ (report, cb) => {
|
|
|
+ userModel
|
|
|
+ .findById(report.createdBy)
|
|
|
+ .select({ avatar: -1, name: -1, username: -1 })
|
|
|
+ .exec((err, user) => {
|
|
|
+ if (!user)
|
|
|
+ reports.push({
|
|
|
+ ...report._doc,
|
|
|
+ createdBy: { _id: report.createdBy }
|
|
|
+ });
|
|
|
+ else
|
|
|
+ reports.push({
|
|
|
+ ...report._doc,
|
|
|
+ createdBy: {
|
|
|
+ avatar: user.avatar,
|
|
|
+ name: user.name,
|
|
|
+ username: user.username,
|
|
|
+ _id: report.createdBy
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return cb(err);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ err => next(err, reports)
|
|
|
+ );
|
|
|
}
|
|
|
],
|
|
|
async (err, reports) => {
|
|
@@ -158,6 +224,7 @@ export default {
|
|
|
this.log("ERROR", "GET_REPORTS_FOR_SONG", `Indexing reports for song "${songId}" failed. "${err}"`);
|
|
|
return cb({ status: "error", message: err });
|
|
|
}
|
|
|
+
|
|
|
this.log("SUCCESS", "GET_REPORTS_FOR_SONG", `Indexing reports for song "${songId}" successful.`);
|
|
|
return cb({ status: "success", data: { reports } });
|
|
|
}
|
|
@@ -165,36 +232,107 @@ export default {
|
|
|
}),
|
|
|
|
|
|
/**
|
|
|
- * Resolves a report
|
|
|
+ * Gets all a users reports for a specific songId
|
|
|
+ *
|
|
|
+ * @param {object} session - the session object automatically added by the websocket
|
|
|
+ * @param {string} songId - the id of the song
|
|
|
+ * @param {Function} cb - gets called with the result
|
|
|
+ */
|
|
|
+ myReportsForSong: isLoginRequired(async function myReportsForSong(session, songId, cb) {
|
|
|
+ const reportModel = await DBModule.runJob("GET_MODEL", { modelName: "report" }, this);
|
|
|
+ const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }, this);
|
|
|
+
|
|
|
+ async.waterfall(
|
|
|
+ [
|
|
|
+ next =>
|
|
|
+ reportModel
|
|
|
+ .find({ "song._id": songId, createdBy: session.userId, resolved: false })
|
|
|
+ .sort({ createdAt: "desc" })
|
|
|
+ .exec(next),
|
|
|
+
|
|
|
+ (_reports, next) => {
|
|
|
+ const reports = [];
|
|
|
+
|
|
|
+ async.each(
|
|
|
+ _reports,
|
|
|
+ (report, cb) => {
|
|
|
+ userModel
|
|
|
+ .findById(report.createdBy)
|
|
|
+ .select({ avatar: -1, name: -1, username: -1 })
|
|
|
+ .exec((err, user) => {
|
|
|
+ if (!user)
|
|
|
+ reports.push({
|
|
|
+ ...report._doc,
|
|
|
+ createdBy: { _id: report.createdBy }
|
|
|
+ });
|
|
|
+ else
|
|
|
+ reports.push({
|
|
|
+ ...report._doc,
|
|
|
+ createdBy: {
|
|
|
+ avatar: user.avatar,
|
|
|
+ name: user.name,
|
|
|
+ username: user.username,
|
|
|
+ _id: report.createdBy
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return cb(err);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ err => next(err, reports)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ async (err, reports) => {
|
|
|
+ if (err) {
|
|
|
+ err = await UtilsModule.runJob("GET_ERROR", { error: err }, this);
|
|
|
+ this.log(
|
|
|
+ "ERROR",
|
|
|
+ "MY_REPORTS_FOR_SONG",
|
|
|
+ `Indexing reports of user ${session.userId} for song "${songId}" failed. "${err}"`
|
|
|
+ );
|
|
|
+ return cb({ status: "error", message: err });
|
|
|
+ }
|
|
|
+
|
|
|
+ this.log(
|
|
|
+ "SUCCESS",
|
|
|
+ "MY_REPORTS_FOR_SONG",
|
|
|
+ `Indexing reports of user ${session.userId} for song "${songId}" successful.`
|
|
|
+ );
|
|
|
+
|
|
|
+ return cb({ status: "success", data: { reports } });
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }),
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Resolves a report as a whole
|
|
|
*
|
|
|
* @param {object} session - the session object automatically added by the websocket
|
|
|
* @param {string} reportId - the id of the report that is getting resolved
|
|
|
* @param {Function} cb - gets called with the result
|
|
|
*/
|
|
|
resolve: isAdminRequired(async function resolve(session, reportId, cb) {
|
|
|
- const reportModel = await DBModule.runJob(
|
|
|
- "GET_MODEL",
|
|
|
- {
|
|
|
- modelName: "report"
|
|
|
- },
|
|
|
- this
|
|
|
- );
|
|
|
+ const reportModel = await DBModule.runJob("GET_MODEL", { modelName: "report" }, this);
|
|
|
+
|
|
|
async.waterfall(
|
|
|
[
|
|
|
next => {
|
|
|
- reportModel.findOne({ _id: reportId }).exec(next);
|
|
|
+ reportModel.findById(reportId).exec(next);
|
|
|
},
|
|
|
|
|
|
(report, next) => {
|
|
|
if (!report) return next("Report not found.");
|
|
|
+
|
|
|
report.resolved = true;
|
|
|
+
|
|
|
return report.save(err => {
|
|
|
if (err) return next(err.message);
|
|
|
- return next();
|
|
|
+ return next(null, report.song._id);
|
|
|
});
|
|
|
}
|
|
|
],
|
|
|
- async err => {
|
|
|
+ async (err, songId) => {
|
|
|
if (err) {
|
|
|
err = await UtilsModule.runJob("GET_ERROR", { error: err }, this);
|
|
|
this.log(
|
|
@@ -204,11 +342,14 @@ export default {
|
|
|
);
|
|
|
return cb({ status: "error", message: err });
|
|
|
}
|
|
|
+
|
|
|
CacheModule.runJob("PUB", {
|
|
|
channel: "report.resolve",
|
|
|
- value: reportId
|
|
|
+ value: { reportId, songId }
|
|
|
});
|
|
|
+
|
|
|
this.log("SUCCESS", "REPORTS_RESOLVE", `User "${session.userId}" resolved report "${reportId}".`);
|
|
|
+
|
|
|
return cb({
|
|
|
status: "success",
|
|
|
message: "Successfully resolved Report"
|
|
@@ -218,22 +359,83 @@ export default {
|
|
|
}),
|
|
|
|
|
|
/**
|
|
|
- * Creates a new report
|
|
|
+ * Resolves/Unresolves an issue within a report
|
|
|
*
|
|
|
* @param {object} session - the session object automatically added by the websocket
|
|
|
- * @param {object} data - the object of the report data
|
|
|
+ * @param {string} reportId - the id of the report that is getting resolved
|
|
|
+ * @param {string} issueId - the id of the issue within the report
|
|
|
* @param {Function} cb - gets called with the result
|
|
|
*/
|
|
|
- create: isLoginRequired(async function create(session, data, cb) {
|
|
|
+ toggleIssue: isAdminRequired(async function toggleIssue(session, reportId, issueId, cb) {
|
|
|
const reportModel = await DBModule.runJob("GET_MODEL", { modelName: "report" }, this);
|
|
|
- const songModel = await DBModule.runJob("GET_MODEL", { modelName: "song" }, this);
|
|
|
|
|
|
async.waterfall(
|
|
|
[
|
|
|
next => {
|
|
|
- songModel.findOne({ youtubeId: data.youtubeId }).exec(next);
|
|
|
+ reportModel.findById(reportId).exec(next);
|
|
|
},
|
|
|
|
|
|
+ (report, next) => {
|
|
|
+ if (!report) return next("Report not found.");
|
|
|
+
|
|
|
+ const issue = report.issues.find(issue => issue._id.toString() === issueId);
|
|
|
+ issue.resolved = !issue.resolved;
|
|
|
+
|
|
|
+ return report.save(err => {
|
|
|
+ if (err) return next(err.message);
|
|
|
+ return next(null, issue.resolved, report.song._id);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ async (err, resolved, songId) => {
|
|
|
+ if (err) {
|
|
|
+ err = await UtilsModule.runJob("GET_ERROR", { error: err }, this);
|
|
|
+ this.log(
|
|
|
+ "ERROR",
|
|
|
+ "REPORTS_TOGGLE_ISSUE",
|
|
|
+ `Resolving an issue within report "${reportId}" failed by user "${session.userId}". "${err}"`
|
|
|
+ );
|
|
|
+ return cb({ status: "error", message: err });
|
|
|
+ }
|
|
|
+
|
|
|
+ CacheModule.runJob("PUB", {
|
|
|
+ channel: "report.issue.toggle",
|
|
|
+ value: { reportId, issueId, songId, resolved }
|
|
|
+ });
|
|
|
+
|
|
|
+ this.log(
|
|
|
+ "SUCCESS",
|
|
|
+ "REPORTS_TOGGLE_ISSUE",
|
|
|
+ `User "${session.userId}" resolved an issue in report "${reportId}".`
|
|
|
+ );
|
|
|
+
|
|
|
+ return cb({
|
|
|
+ status: "success",
|
|
|
+ message: "Successfully resolved issue within report"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }),
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Creates a new report
|
|
|
+ *
|
|
|
+ * @param {object} session - the session object automatically added by the websocket
|
|
|
+ * @param {object} report - the object of the report data
|
|
|
+ * @param {string} report.youtubeId - the youtube id of the song that is being reported
|
|
|
+ * @param {Array} report.issues - all issues reported (custom or defined)
|
|
|
+ * @param {Function} cb - gets called with the result
|
|
|
+ */
|
|
|
+ create: isLoginRequired(async function create(session, report, cb) {
|
|
|
+ const reportModel = await DBModule.runJob("GET_MODEL", { modelName: "report" }, this);
|
|
|
+ const songModel = await DBModule.runJob("GET_MODEL", { modelName: "song" }, this);
|
|
|
+
|
|
|
+ const { youtubeId } = report;
|
|
|
+
|
|
|
+ async.waterfall(
|
|
|
+ [
|
|
|
+ next => songModel.findOne({ youtubeId }).exec(next),
|
|
|
+
|
|
|
(song, next) => {
|
|
|
if (!song) return next("Song not found.");
|
|
|
|
|
@@ -245,54 +447,24 @@ export default {
|
|
|
(song, next) => {
|
|
|
if (!song) return next("Song not found.");
|
|
|
|
|
|
- delete data.youtubeId;
|
|
|
- data.song = {
|
|
|
+ delete report.youtubeId;
|
|
|
+ report.song = {
|
|
|
_id: song._id,
|
|
|
youtubeId: song.youtubeId
|
|
|
};
|
|
|
|
|
|
- for (let z = 0; z < data.issues.length; z += 1) {
|
|
|
- if (reportableIssues.filter(issue => issue.name === data.issues[z].name).length > 0) {
|
|
|
- for (let r = 0; r < reportableIssues.length; r += 1) {
|
|
|
- if (
|
|
|
- reportableIssues[r].reasons.every(
|
|
|
- reason => data.issues[z].reasons.indexOf(reason) < -1
|
|
|
- )
|
|
|
- ) {
|
|
|
- return cb({
|
|
|
- status: "error",
|
|
|
- message: "Invalid data"
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- } else
|
|
|
- return cb({
|
|
|
- status: "error",
|
|
|
- message: "Invalid data"
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
return next(null, { title: song.title, artists: song.artists, thumbnail: song.thumbnail });
|
|
|
},
|
|
|
|
|
|
- (song, next) => {
|
|
|
- const issues = [];
|
|
|
-
|
|
|
- for (let r = 0; r < data.issues.length; r += 1) {
|
|
|
- if (!data.issues[r].reasons.length <= 0) issues.push(data.issues[r]);
|
|
|
- }
|
|
|
-
|
|
|
- data.issues = issues;
|
|
|
-
|
|
|
- next(null, song);
|
|
|
- },
|
|
|
-
|
|
|
- (song, next) => {
|
|
|
- data.createdBy = session.userId;
|
|
|
- data.createdAt = Date.now();
|
|
|
-
|
|
|
- reportModel.create(data, (err, report) => next(err, report, song));
|
|
|
- }
|
|
|
+ (song, next) =>
|
|
|
+ reportModel.create(
|
|
|
+ {
|
|
|
+ createdBy: session.userId,
|
|
|
+ createdAt: Date.now(),
|
|
|
+ ...report
|
|
|
+ },
|
|
|
+ (err, report) => next(err, report, song)
|
|
|
+ )
|
|
|
],
|
|
|
async (err, report, song) => {
|
|
|
if (err) {
|
|
@@ -300,31 +472,28 @@ export default {
|
|
|
this.log(
|
|
|
"ERROR",
|
|
|
"REPORTS_CREATE",
|
|
|
- `Creating report for "${data.song._id}" failed by user "${session.userId}". "${err}"`
|
|
|
+ `Creating report for "${report.song._id}" failed by user "${session.userId}". "${err}"`
|
|
|
);
|
|
|
return cb({ status: "error", message: err });
|
|
|
}
|
|
|
|
|
|
- CacheModule.runJob("PUB", {
|
|
|
- channel: "report.create",
|
|
|
- value: report
|
|
|
- });
|
|
|
-
|
|
|
ActivitiesModule.runJob("ADD_ACTIVITY", {
|
|
|
- userId: report.createdBy,
|
|
|
+ userId: session.userId,
|
|
|
type: "song__report",
|
|
|
payload: {
|
|
|
- message: `Reported song <youtubeId>${song.title} by ${song.artists.join(", ")}</youtubeId>`,
|
|
|
- youtubeId: data.song.youtubeId,
|
|
|
+ message: `Created a <reportId>${report._id}</reportId> for song <youtubeId>${song.title}</youtubeId>`,
|
|
|
+ youtubeId: report.song.youtubeId,
|
|
|
+ reportId: report._id,
|
|
|
thumbnail: song.thumbnail
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- this.log(
|
|
|
- "SUCCESS",
|
|
|
- "REPORTS_CREATE",
|
|
|
- `User "${session.userId}" created report for "${data.youtubeId}".`
|
|
|
- );
|
|
|
+ CacheModule.runJob("PUB", {
|
|
|
+ channel: "report.create",
|
|
|
+ value: report
|
|
|
+ });
|
|
|
+
|
|
|
+ this.log("SUCCESS", "REPORTS_CREATE", `User "${session.userId}" created report for "${youtubeId}".`);
|
|
|
|
|
|
return cb({
|
|
|
status: "success",
|