mirror of
https://github.com/wassname/talk.git
synced 2026-08-01 13:00:55 +08:00
Graph fixes and migrations
- Added migrations for mapping old keys - Added migration for fixing old dont agree flags - Removed enum requirement for output
This commit is contained in:
@@ -267,7 +267,7 @@ const moderationPhases = [
|
||||
actions: [{
|
||||
action_type: 'FLAG',
|
||||
user_id: null,
|
||||
group_id: 'Matched suspect word filter',
|
||||
group_id: 'SUSPECT_WORD',
|
||||
metadata: {}
|
||||
}],
|
||||
};
|
||||
@@ -302,7 +302,7 @@ const moderationPhases = [
|
||||
|
||||
// Add the flag related to Trust to the comment.
|
||||
return {
|
||||
status:'SYSTEM_WITHHELD',
|
||||
status: 'SYSTEM_WITHHELD',
|
||||
actions: [{
|
||||
action_type: 'FLAG',
|
||||
user_id: null,
|
||||
|
||||
@@ -555,7 +555,7 @@ type FlagAction implements Action {
|
||||
id: ID!
|
||||
|
||||
# The reason for which the Flag Action was created.
|
||||
reason: FLAG_REASON
|
||||
reason: String
|
||||
|
||||
# An optional message sent with the flagging action by the user.
|
||||
message: String
|
||||
@@ -596,7 +596,7 @@ type FlagActionSummary implements ActionSummary {
|
||||
count: Int!
|
||||
|
||||
# The reason for which the Flag Action was created.
|
||||
reason: FLAG_REASON
|
||||
reason: String
|
||||
|
||||
# The flag by the current user against the parent entity with this reason.
|
||||
current_user: FlagAction
|
||||
|
||||
@@ -263,6 +263,11 @@ en:
|
||||
comment_spam: "Spam"
|
||||
comment_noagree: "Disagree"
|
||||
comment_other: "Other"
|
||||
suspect_word: "Suspect Word"
|
||||
banned_word: "Banned Word"
|
||||
body_count: "Body exceeds max length"
|
||||
links: "Links"
|
||||
trust: "Trust"
|
||||
modqueue:
|
||||
account: "account flags"
|
||||
actions: Actions
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
const ActionModel = require('../models/action');
|
||||
|
||||
const mapping = {
|
||||
COMMENTS: {
|
||||
'Comment contains toxic language': 'TOXIC_COMMENT',
|
||||
'Matched suspect word filter': 'SUSPECT_WORD',
|
||||
'other': 'COMMENT_OTHER',
|
||||
'Other': 'COMMENT_OTHER',
|
||||
'This looks like an ad/marketing': 'COMMENT_SPAM',
|
||||
'This comment is offensive': 'COMMENT_OFFENSIVE',
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
async up() {
|
||||
|
||||
// Setup the batch operation.
|
||||
const batch = ActionModel.collection.initializeUnorderedBulkOp();
|
||||
|
||||
for (const item_type in mapping) {
|
||||
const mappings = mapping[item_type];
|
||||
|
||||
for (const OLD_GROUP_ID in mappings) {
|
||||
const NEW_GROUP_ID = mappings[OLD_GROUP_ID];
|
||||
|
||||
// OLD
|
||||
// {
|
||||
// group_id: <OLD_GROUP_ID>
|
||||
// }
|
||||
// NEW
|
||||
// {
|
||||
// group_id: <NEW_GROUP_ID>
|
||||
// }
|
||||
|
||||
batch.find({
|
||||
group_id: OLD_GROUP_ID,
|
||||
item_type,
|
||||
}).update({
|
||||
$set: {
|
||||
group_id: NEW_GROUP_ID,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Execute the batch update operation.
|
||||
await batch.execute();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
const ActionModel = require('../models/action');
|
||||
|
||||
module.exports = {
|
||||
async up() {
|
||||
|
||||
// This will update all the old flags that are 'COMMENT_NOAGREE' to change
|
||||
// them to DONTAGREE actions instead.
|
||||
return ActionModel.update({
|
||||
action_type: 'FLAG',
|
||||
group_id: 'COMMENT_NOAGREE',
|
||||
}, {
|
||||
$set: {
|
||||
action_type: 'DONTAGREE',
|
||||
group_id: null,
|
||||
},
|
||||
}, {
|
||||
multi: true,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
},
|
||||
"talk": {
|
||||
"migration": {
|
||||
"minVersion": 1496771633
|
||||
"minVersion": 1507322128
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
||||
Reference in New Issue
Block a user