-
Notifications
You must be signed in to change notification settings - Fork 36
ARR: Add comment preprocess for links #2976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 6 commits
b0d39fe
d326c44
0db0637
73deb4c
dcd1051
8307242
d23f6b2
bba5373
1b02cf3
728c3df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| async function process(client, edit, invitation) { | ||
| client.throwErrors = true | ||
|
|
||
| const { note } = edit | ||
| if (note.ddate) { | ||
| return | ||
| } | ||
|
|
||
| const [res1, res2] = await Promise.all([ | ||
| client.getNotes({ id: note.forum }), | ||
| client.getGroups({ id: invitation.domain }), | ||
| ]) | ||
| const forum = res1.notes[0] | ||
| const domain = res2.groups[0] | ||
| const readers = note.readers || [] | ||
| const authorsName = domain.content?.authors_name?.value || "Authors" | ||
| const authorGroupId = `${domain.id}/Submission${forum.number}/${authorsName}` | ||
| const commentText = note.content?.comment?.value || "" | ||
| const linkPattern = | ||
| /\[[^\]]+\]\([^)]+\)|<?(?:https?:\/\/|www\.)\S+>?|\b[a-z0-9.-]+\.[a-z]{2,}\/\S*/i | ||
|
|
||
| if ((readers.includes(authorGroupId) || readers.includes("everyone")) && linkPattern.test(commentText)) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. have you tried setting a regex in the comment field of the Official_Comment invitation?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The regex would apply to all comments, so this would disallow links in comments between reviewers/ACs/SACs right? The request is "authors could be prevented from submitting responses to reviewers" which I think needs extra logic |
||
| return Promise.reject( | ||
| new OpenReviewError({ | ||
| name: "Error", | ||
| message: "Links are not allowed in official comments that are visible to authors.", | ||
| }) | ||
| ) | ||
| } | ||
|
|
||
| if (readers.includes("everyone")) { | ||
| return | ||
| } | ||
|
|
||
| const commentMandatoryReaders = | ||
| domain.content?.comment_mandatory_readers?.value || [] | ||
| for (const m of commentMandatoryReaders) { | ||
| const reader = m.replace("{number}", forum.number) | ||
| if (!readers.includes(reader)) { | ||
| return Promise.reject( | ||
| new OpenReviewError({ | ||
| name: "Error", | ||
| message: reader + " must be readers of the comment", | ||
| }) | ||
| ) | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.