Implement reporting of groups, a start

This commit is contained in:
Wolfgang Huß 2022-10-03 12:48:41 +02:00
parent 77f2a65663
commit b4f11c5838
7 changed files with 150 additions and 60 deletions

View File

@ -11,9 +11,14 @@ export default {
`
MATCH (submitter:User {id: $submitterId})
MATCH (resource {id: $resourceId})
WHERE resource:User OR resource:Post OR resource:Comment
WHERE resource:User OR resource:Group OR resource:Post OR resource:Comment
MERGE (resource)<-[:BELONGS_TO]-(report:Report {closed: false})
ON CREATE SET report.id = randomUUID(), report.createdAt = $createdAt, report.updatedAt = report.createdAt, report.rule = 'latestReviewUpdatedAtRules', report.disable = resource.disabled, report.closed = false
ON CREATE SET report.id = randomUUID(),
report.createdAt = $createdAt,
report.updatedAt = report.createdAt,
report.rule = 'latestReviewUpdatedAtRules',
report.disable = resource.disabled,
report.closed = false
WITH submitter, resource, report
CREATE (report)<-[filed:FILED {createdAt: $createdAt, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription}]-(submitter)
@ -86,16 +91,16 @@ export default {
// !!! this Cypher query returns multiple reports on the same resource! i will create an issue for refactoring (bug fixing)
`
MATCH (report:Report)-[:BELONGS_TO]->(resource)
WHERE (resource:User OR resource:Post OR resource:Comment)
WHERE resource:User OR resource:Group OR resource:Post OR resource:Comment
${filterClause}
WITH report, resource,
[(submitter:User)-[filed:FILED]->(report) | filed {.*, submitter: properties(submitter)} ] as filed,
[(moderator:User)-[reviewed:REVIEWED]->(report) | reviewed {.*, moderator: properties(moderator)} ] as reviewed,
[(resource)<-[:WROTE]-(author:User) | author {.*} ] as optionalAuthors,
[(resource)-[:COMMENTS]->(post:Post) | post {.*} ] as optionalCommentedPosts,
resource {.*, __typename: labels(resource)[0] } as resourceWithType
[(submitter:User)-[filed:FILED]->(report) | filed {.*, submitter: properties(submitter)} ] as filed,
[(moderator:User)-[reviewed:REVIEWED]->(report) | reviewed {.*, moderator: properties(moderator)} ] as reviewed,
[(resource)<-[:WROTE]-(author:User) | author {.*} ] as optionalAuthors,
[(resource)-[:COMMENTS]->(post:Post) | post {.*} ] as optionalCommentedPosts,
resource {.*, __typename: labels(resource)[0] } as resourceWithType
WITH report, optionalAuthors, optionalCommentedPosts, reviewed, filed,
resourceWithType {.*, post: optionalCommentedPosts[0], author: optionalAuthors[0] } as finalResource
resourceWithType {.*, post: optionalCommentedPosts[0], author: optionalAuthors[0] } as finalResource
RETURN report {.*, resource: finalResource, filed: filed, reviewed: reviewed }
${orderByClause}
${offset} ${limit}

View File

@ -10,7 +10,7 @@ type Report {
resource: ReportedResource!
}
union ReportedResource = User | Post | Comment
union ReportedResource = User | Group | Post | Comment
enum ReportRule {
latestReviewUpdatedAtRules

View File

@ -62,16 +62,31 @@ export default {
params: { id: this.group.id, slug: this.group.slug },
})
}
if (this.group.myRole === 'owner') {
if (this.isOwner) {
routes.push({
label: this.$t('admin.settings.name'),
path: `/group/edit/${this.group.id}`,
icon: 'edit',
})
}
if (!this.isOwner) {
routes.push({
label: this.$t(`report.${this.resourceType}.title`),
callback: () => {
this.openModal('report')
},
icon: 'flag',
})
}
return routes
},
isOwner() {
return this.group.myRole === 'owner'
},
resourceType() {
return 'group'
},
},
methods: {
openItem(route, toggleMenu) {
@ -82,6 +97,16 @@ export default {
}
toggleMenu()
},
openModal(dialog, modalDataName = null) {
this.$store.commit('modal/SET_OPEN', {
name: dialog,
data: {
type: this.resourceType,
resource: this.group,
modalData: modalDataName ? this.modalsData[modalDataName] : {},
},
})
},
},
}
</script>

View File

@ -115,16 +115,48 @@ export default {
return reviewed && reviewed.length
},
iconName() {
if (this.isPost) return 'bookmark'
else if (this.isComment) return 'comments'
else if (this.isUser) return 'user'
else return null
let name
switch (this.report.resource.__typename) {
case 'User':
name = 'user'
break
case 'Group':
name = 'users'
break
case 'Post':
name = 'bookmark'
break
case 'Comment':
name = 'comments'
break
default:
name = null
break
}
return name
},
iconLabel() {
if (this.isPost) return this.$t('report.contribution.type')
else if (this.isComment) return this.$t('report.comment.type')
else if (this.isUser) return this.$t('report.user.type')
else return null
let label
switch (this.report.resource.__typename) {
case 'User':
label = this.$t('report.user.type')
break
case 'Group':
label = this.$t('report.group.type')
break
case 'Post':
label = this.$t('report.contribution.type')
break
case 'Comment':
label = this.$t('report.comment.type')
break
default:
label = null
break
}
return label
},
linkTarget() {
const { id, slug } = this.isComment ? this.report.resource.post : this.report.resource
@ -135,9 +167,26 @@ export default {
}
},
linkText() {
return (
this.report.resource.title || this.$filters.removeHtml(this.report.resource.contentExcerpt)
)
let text
switch (this.report.resource.__typename) {
case 'User':
text = '' // user avatar is used
break
case 'Group':
text = this.report.resource.name
break
case 'Post':
text = this.report.resource.title
break
case 'Comment':
text = this.$filters.removeHtml(this.report.resource.contentExcerpt)
break
default:
text = null
break
}
return text
},
statusIconName() {
return this.isDisabled ? 'eye-slash' : 'eye'

View File

@ -288,13 +288,13 @@
"delete": {
"cancel": "Abbrechen",
"comment": {
"message": "Bist Du sicher, dass Du den Kommentar <b>{name}</b> löschen möchtest?",
"message": "Bist Du sicher, dass Du den Kommentar <b>{name}</b> löschen möchtest?",
"success": "Kommentar erfolgreich gelöscht!",
"title": "Lösche Kommentar",
"type": "Kommentar"
},
"contribution": {
"message": "Bist Du sicher, dass Du den Beitrag <b>{name}</b> löschen möchtest?",
"message": "Bist Du sicher, dass Du den Beitrag <b>{name}</b> löschen möchtest?",
"success": "Beitrag erfolgreich gelöscht!",
"title": "Lösche Beitrag",
"type": "Beitrag"
@ -304,19 +304,19 @@
"disable": {
"cancel": "Abbrechen",
"comment": {
"message": "Bist Du sicher, dass Du den Kommentar <b>{name}</b> deaktivieren möchtest?",
"message": "Bist Du sicher, dass Du den Kommentar <b>{name}</b> deaktivieren möchtest?",
"title": "Kommentar sperren",
"type": "Kommentar"
},
"contribution": {
"message": "Bist Du sicher, dass Du den Beitrag von <b>{name}</b> deaktivieren möchtest?",
"message": "Bist Du sicher, dass Du den Beitrag von <b>{name}</b> deaktivieren möchtest?",
"title": "Beitrag sperren",
"type": "Beitrag"
},
"submit": "Deaktivieren",
"success": "Erfolgreich deaktiviert",
"user": {
"message": "Bist Du sicher, dass Du den Nutzer <b>{name}</b> sperren möchtest?",
"message": "Bist Du sicher, dass Du den Nutzer <b>{name}</b> sperren möchtest?",
"title": "Nutzer sperren",
"type": "Nutzer"
}
@ -522,32 +522,32 @@
"cancel": "Abbruch",
"Comment": {
"disable": {
"message": "Möchtest Du den Kommentar <b>{name}</b> wirklich <b>gesperrt</b> lassen?",
"message": "Möchtest Du den Kommentar <b>{name}</b> wirklich <b>gesperrt</b> lassen?",
"title": "Sperre den Kommentar abschließend"
},
"enable": {
"message": "Möchtest Du den Kommentar <b>{name}</b> wirklich <b>entsperrt</b> lassen?",
"message": "Möchtest Du den Kommentar <b>{name}</b> wirklich <b>entsperrt</b> lassen?",
"title": "Entsperre den Kommentar abschließend"
}
},
"Post": {
"disable": {
"message": "Möchtest Du den Beitrag <b>{name}</b> wirklich <b>gesperrt</b> lassen?",
"message": "Möchtest Du den Beitrag <b>{name}</b> wirklich <b>gesperrt</b> lassen?",
"title": "Sperre den Beitrag abschließend"
},
"enable": {
"message": "Möchtest Du den Beitrag <b>{name}</b> wirklich <b>entsperrt</b> lassen?",
"message": "Möchtest Du den Beitrag <b>{name}</b> wirklich <b>entsperrt</b> lassen?",
"title": "Entsperre den Beitrag abschließend"
}
},
"submit": "Bestätige Entscheidung",
"User": {
"disable": {
"message": "Möchtest Du den Benutzer <b>{name}</b> wirklich <b>gesperrt</b> lassen?",
"message": "Möchtest Du den Benutzer <b>{name}</b> wirklich <b>gesperrt</b> lassen?",
"title": "Sperre den Benutzer abschließend"
},
"enable": {
"message": "Möchtest Du den Benutzer <b>{name}</b> wirklich <b>entsperrt</b> lassen?",
"message": "Möchtest Du den Benutzer <b>{name}</b> wirklich <b>entsperrt</b> lassen?",
"title": "Entsperre den Benutzer abschließend"
}
}
@ -656,13 +656,13 @@
"cancel": "Abbrechen",
"comment": {
"error": "Den Kommentar hast Du schon gemeldet!",
"message": "Bist Du sicher, dass Du den Kommentar <b>{name}</b> freigeben möchtest?",
"message": "Bist Du sicher, dass Du den Kommentar <b>{name}</b> freigeben möchtest?",
"title": "Kommentar freigeben",
"type": "Kommentar"
},
"contribution": {
"error": "Den Beitrag hast Du schon gemeldet!",
"message": "Bist Du sicher, dass Du den Beitrag <b>{name}</b> freigeben möchtest?",
"message": "Bist Du sicher, dass Du den Beitrag <b>{name}</b> freigeben möchtest?",
"title": "Beitrag freigeben",
"type": "Beitrag"
},
@ -670,7 +670,7 @@
"success": "Erfolgreich freigegeben!",
"user": {
"error": "Den Benutzer hast Du schon gemeldet!",
"message": "Bist Du sicher, dass Du den Nutzer <b>{name}</b> freigeben möchtest?",
"message": "Bist Du sicher, dass Du den Nutzer <b>{name}</b> freigeben möchtest?",
"title": "Nutzer freigeben",
"type": "Nutzer"
}
@ -679,16 +679,22 @@
"cancel": "Abbrechen",
"comment": {
"error": "Du hast den Kommentar bereits gemeldet!",
"message": "Bist Du sicher, dass Du den Kommentar von <b>{name}</b> melden möchtest?",
"message": "Bist Du sicher, dass Du den Kommentar von <b>{name}</b> melden möchtest?",
"title": "Kommentar melden",
"type": "Kommentar"
},
"contribution": {
"error": "Du hast den Beitrag bereits gemeldet!",
"message": "Bist Du sicher, dass Du den Beitrag <b>{name}</b> melden möchtest?",
"message": "Bist Du sicher, dass Du den Beitrag <b>{name}</b> melden möchtest?",
"title": "Beitrag melden",
"type": "Beitrag"
},
"group": {
"error": "Du hast die Gruppe bereits gemeldet!",
"message": "Bist Du sicher, dass Du die Gruppe <b>„{name}“</b> melden möchtest?",
"title": "Gruppe melden",
"type": "Gruppe"
},
"reason": {
"category": {
"invalid": "Bitte wähle ein gültiges Thema aus",
@ -714,7 +720,7 @@
"success": "Vielen Dank für diese Meldung!",
"user": {
"error": "Du hast den Benutzer bereits gemeldet!",
"message": "Bist Du sicher, dass Du den Nutzer <b>{name}</b> melden möchtest?",
"message": "Bist Du sicher, dass Du den Nutzer <b>{name}</b> melden möchtest?",
"title": "Nutzer melden",
"type": "Nutzer"
}

View File

@ -288,13 +288,13 @@
"delete": {
"cancel": "Cancel",
"comment": {
"message": "Do you really want to delete the comment \"<b>{name}</b>\"?",
"message": "Do you really want to delete the comment <b>{name}</b>?",
"success": "Comment successfully deleted!",
"title": "Delete Comment",
"type": "Comment"
},
"contribution": {
"message": "Do you really want to delete the post \"<b>{name}</b>\"?",
"message": "Do you really want to delete the post <b>{name}</b>?",
"success": "Post successfully deleted!",
"title": "Delete Post",
"type": "Contribution"
@ -304,19 +304,19 @@
"disable": {
"cancel": "Cancel",
"comment": {
"message": "Do you really want to disable the comment from \"<b>{name}</b>\"?",
"message": "Do you really want to disable the comment from <b>{name}</b>?",
"title": "Disable Comment",
"type": "Comment"
},
"contribution": {
"message": "Do you really want to disable the contribution \"<b>{name}</b>\"?",
"message": "Do you really want to disable the contribution <b>{name}</b>?",
"title": "Disable Contribution",
"type": "Contribution"
},
"submit": "Disable",
"success": "Disabled successfully!",
"user": {
"message": "Do you really want to disable the user \"<b>{name}</b>\"?",
"message": "Do you really want to disable the user <b>{name}</b>?",
"title": "Disable User",
"type": "User"
}
@ -522,32 +522,32 @@
"cancel": "Cancel",
"Comment": {
"disable": {
"message": "Do you really want to let the comment \"<b>{name}</b>\" stay <b>disabled</b>?",
"message": "Do you really want to let the comment <b>{name}</b> stay <b>disabled</b>?",
"title": "Finally Disable Comment"
},
"enable": {
"message": "Do you really want to let the comment \"<b>{name}</b>\" stay <b>enabled</b>?",
"message": "Do you really want to let the comment <b>{name}</b> stay <b>enabled</b>?",
"title": "Finally Enable Comment"
}
},
"Post": {
"disable": {
"message": "Do you really want to let the post \"<b>{name}</b>\" stay <b>disabled</b>?",
"message": "Do you really want to let the post <b>{name}</b> stay <b>disabled</b>?",
"title": "Finally Disable Post"
},
"enable": {
"message": "Do you really want to let the post \"<b>{name}</b>\" stay <b>enabled</b>?",
"message": "Do you really want to let the post <b>{name}</b> stay <b>enabled</b>?",
"title": "Finally Enable Post"
}
},
"submit": "Confirm decision",
"User": {
"disable": {
"message": "Do you really want to let the user \"<b>{name}</b>\" stay <b>disabled</b>?",
"message": "Do you really want to let the user <b>{name}</b> stay <b>disabled</b>?",
"title": "Finally Disable User"
},
"enable": {
"message": "Do you really want to let the user \"<b>{name}</b>\" stay <b>enabled</b>?",
"message": "Do you really want to let the user <b>{name}</b> stay <b>enabled</b>?",
"title": "Finally Enable User"
}
}
@ -656,13 +656,13 @@
"cancel": "Cancel",
"comment": {
"error": "You have already reported the comment!",
"message": "Do you really want to release the comment from \"<b>{name}</b>\"?",
"message": "Do you really want to release the comment from <b>{name}</b>?",
"title": "Release Comment",
"type": "Comment"
},
"contribution": {
"error": "You have already reported the contribution!!",
"message": "Do you really want to release the contribution \"<b>{name}</b>\"?",
"message": "Do you really want to release the contribution <b>{name}</b>?",
"title": "Release Contribution",
"type": "Contribution"
},
@ -670,7 +670,7 @@
"success": "Released successfully!",
"user": {
"error": "You already reported the user!",
"message": "Do you really want to release the user \"<b>{name}</b>\"?",
"message": "Do you really want to release the user <b>{name}</b>?",
"title": "Release User",
"type": "User"
}
@ -679,16 +679,22 @@
"cancel": "Cancel",
"comment": {
"error": "You have already reported the comment!",
"message": "Do you really want to report the comment from \"<b>{name}</b>\"?",
"message": "Do you really want to report the comment from <b>{name}</b>?",
"title": "Report Comment",
"type": "Comment"
},
"contribution": {
"error": "You have already reported the contribution!",
"message": "Do you really want to report the contribution \"<b>{name}</b>\"?",
"message": "Do you really want to report the contribution <b>{name}</b>?",
"title": "Report Post",
"type": "Contribution"
},
"group": {
"error": "You have already reported the group!",
"message": "Do you really want to report the group <b>“{name}”</b>?",
"title": "Report Group",
"type": "Group"
},
"reason": {
"category": {
"invalid": "Please select a valid topic",
@ -697,7 +703,7 @@
"advert_products_services_commercial": "Advertising products and services with commercial intent.",
"criminal_behavior_violation_german_law": "Criminal behavior or violation of German law.",
"discrimination_etc": "Discriminatory posts, comments, utterances or insults.",
"doxing": "The disclosure of others' personal information without their consent or threat there of (\"doxing\").",
"doxing": "The disclosure of others' personal information without their consent or threat there of (“doxing”).",
"glorific_trivia_of_cruel_inhuman_acts": "Glorification or trivialization of cruel or inhuman acts of violence.",
"intentional_intimidation_stalking_persecution": "Intentional intimidation, stalking or persecution.",
"other": "Other …",
@ -714,7 +720,7 @@
"success": "Thanks for reporting!",
"user": {
"error": "You already reported the user!",
"message": "Do you really want to report the user \"<b>{name}</b>\"?",
"message": "Do you really want to report the user <b>{name}</b>?",
"title": "Report User",
"type": "User"
}
@ -728,7 +734,7 @@
"User": "User ::: Users"
},
"hint": "What are you searching for? Use !… for posts, @… for users, #… for hashtags.",
"no-results": "No results found for \"{search}\". Try a different search term!",
"no-results": "No results found for “{search}”. Try a different search term!",
"page": "Page",
"placeholder": "Search",
"results": "result found ::: results found",
@ -881,7 +887,7 @@
},
"social-media": {
"addNewTitle": "Add new link",
"editTitle": "Edit link \"{name}\"",
"editTitle": "Edit link “{name}”",
"name": "Social media",
"placeholder": "Your social media url",
"requireUnique": "You added this url already",

View File

@ -18,7 +18,6 @@
<!-- Menu -->
<client-only>
<group-content-menu
v-if="isGroupOwner"
class="group-content-menu"
:usage="'groupProfile'"
:group="group || {}"