Skip to content
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

Let servers modify messages according to admin-defined Regular Expressions #286

Open
joker314 opened this issue Mar 4, 2018 · 2 comments
Labels
feature NEW THING!!

Comments

@joker314
Copy link
Contributor

joker314 commented Mar 4, 2018

This issue is a feature request.

Every server would be able to define a list of find-and-replace regular expressions. These would be applied to incoming messages before sending them out to all other clients.

For example, let's say "apple" is a very very naughty word. Then, into the decent command line, you could type

decent> add filter /apple/i redacted

The first argument is a regular expression, and the second argument is what the replacement should be. Referencing matched groups can be done through $number. For example, if a server for developing Decent wanted to replace numeric issue numbers with links to their GitHub issue and PRs, they could do

decent> add filter /#([0-9]+)/ [#$1](https://github.com/decent-chat/decent/issues/$1/)

(Note: /issues/ will redirect to /pulls/ automatically if needed).

This is useful because it edits messages in a different way to how a bot would. Main advantages are

  • Still works when bot is offline
  • Bot feels wrong because the content of the message isn't changing and it's spamming the server with unneeded edits for every single message
  • Easy to set up

For more complicated actions, you can of course use a bot.

How should we deal with removing these filters? I propose

decent> ls filter

There are currently 2 filters in place for this server:

+------+-------------+---------------------------------------------------------+
|  ID  | Matches     | Replaced by                                             |
+------+-----------------------+-----------------------------------------------+
|  1   | /#[0-9]+/   | [#$1](https://github.com/decent-chat/decent/issues/$1/) |
+------+-----------------------+-----------------------------------------------+
|  2   | /apple/i    | REDACTED                                                |
+------+------------------+----------------------------------------------------+
decent> delete filter 1

The filter with ID 1 had been removed. It was

/#[0-9]+/ ----> [#$1](https://github.com/decent-chat/decent/issues/$1/)

(aah took me way too long to construct that table in a proportional font)

Or, this could be done on the actual (web)client because it's not too hard to do that and it's not that advanced of a feature.

@PullJosh PullJosh added the feature NEW THING!! label Mar 4, 2018
@joker314
Copy link
Contributor Author

joker314 commented Mar 4, 2018

Hmm I'm not sure how decisions are made here, but let's have a poll!

If you want a Filters server page then react with 👍
If you want a Filters CLI command then react with 👎

@joker314
Copy link
Contributor Author

joker314 commented Mar 4, 2018

Okay, for those wanting to implement the actual filtering bit, I guess this is relevant bit which decides what to do with incoming messages. I suppose the filtering should happen before it even enters the database?

app.post('/api/messages', [

This is separate to how we receive the filter rules though.

@bates64 bates64 changed the title Let servers modify messages according to server-defined Regular Expressions Let servers modify messages according to admin-defined Regular Expressions Mar 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature NEW THING!!
Projects
None yet
Development

No branches or pull requests

2 participants