@yrpri/api 9.0.96 → 9.0.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/controllers/posts.cjs +17 -13
- package/package.json +1 -1
package/controllers/posts.cjs
CHANGED
|
@@ -35,7 +35,7 @@ var changePostCounter = function (req, postId, column, upDown, next) {
|
|
|
35
35
|
};
|
|
36
36
|
//TODO: Refactor this as not to repeate it in controlelrs
|
|
37
37
|
const addAgentFabricUserToSessionIfNeeded = async (req) => {
|
|
38
|
-
let userId =
|
|
38
|
+
let userId = req.user && req.user.id ? req.user.id : null;
|
|
39
39
|
if (!userId &&
|
|
40
40
|
req.query.agentFabricUserId &&
|
|
41
41
|
process.env.PS_TEMP_AGENTS_FABRIC_GROUP_API_KEY &&
|
|
@@ -664,7 +664,7 @@ router.get("/:id/newPoints", auth.can("view post"), function (req, res) {
|
|
|
664
664
|
model: models.Image,
|
|
665
665
|
as: "UserProfileImages",
|
|
666
666
|
required: false,
|
|
667
|
-
through: { attributes: [] }
|
|
667
|
+
through: { attributes: [] },
|
|
668
668
|
},
|
|
669
669
|
],
|
|
670
670
|
},
|
|
@@ -842,7 +842,7 @@ const sendPostPoints = (req, res, redisKey) => {
|
|
|
842
842
|
as: "UserProfileImages",
|
|
843
843
|
attributes: ["id", "formats"],
|
|
844
844
|
required: false,
|
|
845
|
-
through: { attributes: [] }
|
|
845
|
+
through: { attributes: [] },
|
|
846
846
|
},
|
|
847
847
|
],
|
|
848
848
|
},
|
|
@@ -1144,10 +1144,18 @@ router.post("/:groupId", auth.can("create post"), async function (req, res) {
|
|
|
1144
1144
|
if (!error && post) {
|
|
1145
1145
|
post.setDataValue("newEndorsement", endorsement);
|
|
1146
1146
|
log.info("process-moderation post toxicity in post controller");
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1147
|
+
const skipModerationForAgentFabric = !req.query.skipModerationForAgentFabric &&
|
|
1148
|
+
process.env
|
|
1149
|
+
.PS_TEMP_AGENTS_FABRIC_GROUP_API_KEY &&
|
|
1150
|
+
req.headers["x-api-key"] ===
|
|
1151
|
+
process.env
|
|
1152
|
+
.PS_TEMP_AGENTS_FABRIC_GROUP_API_KEY;
|
|
1153
|
+
if (!skipModerationForAgentFabric) {
|
|
1154
|
+
queue.add("process-moderation", {
|
|
1155
|
+
type: "estimate-post-toxicity",
|
|
1156
|
+
postId: post.id,
|
|
1157
|
+
}, "high");
|
|
1158
|
+
}
|
|
1151
1159
|
queue.add("process-moderation", {
|
|
1152
1160
|
type: "post-review-and-annotate-images",
|
|
1153
1161
|
postId: post.id,
|
|
@@ -1849,9 +1857,7 @@ router.delete("/:id/endorse", auth.can("vote on post"), function (req, res) {
|
|
|
1849
1857
|
endorsement.save().then(function () {
|
|
1850
1858
|
if (oldEndorsementValue > 0) {
|
|
1851
1859
|
changePostCounter(req, req.params.id, "counter_endorsements_up", -1, function () {
|
|
1852
|
-
res
|
|
1853
|
-
.status(200)
|
|
1854
|
-
.send({
|
|
1860
|
+
res.status(200).send({
|
|
1855
1861
|
endorsement: endorsement,
|
|
1856
1862
|
oldEndorsementValue: oldEndorsementValue,
|
|
1857
1863
|
});
|
|
@@ -1859,9 +1865,7 @@ router.delete("/:id/endorse", auth.can("vote on post"), function (req, res) {
|
|
|
1859
1865
|
}
|
|
1860
1866
|
else if (oldEndorsementValue < 0) {
|
|
1861
1867
|
changePostCounter(req, req.params.id, "counter_endorsements_down", -1, function () {
|
|
1862
|
-
res
|
|
1863
|
-
.status(200)
|
|
1864
|
-
.send({
|
|
1868
|
+
res.status(200).send({
|
|
1865
1869
|
endorsement: endorsement,
|
|
1866
1870
|
oldEndorsementValue: oldEndorsementValue,
|
|
1867
1871
|
});
|