Add API parameter to safeguard unexpect mentions in new posts
Add optional safeguard_mentions parameter to POST /api/v1/statuses.
When this parameters is set (to a possibly empty list of account IDs) and processing the status text leads to mentions to accounts not listed in safeguard_mentions, the server does not save the status and instead returns an error with an extra_accounts attribute listing the mentioned accounts that caused the error.
The goal of this API parameter is to allow clients to warn users of unexpected mentions: a somewhat common error for newcomers is to accidentally send a DM to a person they did not expect. “Unexpected mentions” is left to the appreciation of the client, but a possible possible interpretation would be “any mention that is not at the beginning of the post”.
This API was designed to ensure that a warning feature would not not trigger for unresolvable mention-like strings, nor let unexpected mentions slip because of client bugs or temporary network issues. Indeed, the client may not have resolved all mentioned accounts, especially if those were copy-pasted or not known to the server yet. Doing this purely client-side would involve the client sending multiple lookup requests and only sending the post after they all returned, and could still let a temporary failure or race condition slip, although this is very unlikely. Involving the server makes sense as it does look up the mentioned accounts at posting time and is authoritative on who would be mentioned.
ping @Gargron
@Gargron do you mind reviewing this?
@Gargron Would it be possible to have your opinion on this?
This pull request has merge conflicts that must be resolved before it can be merged.
Looks like the only build failure here is the Prettier issue that was already fixed