Rocket.Chat.Apps-engine icon indicating copy to clipboard operation
Rocket.Chat.Apps-engine copied to clipboard

Add IModify to executePreMessageSentPrevent

Open cuonghuunguyen opened this issue 4 years ago • 3 comments

In case we want to process the message but don't want to add the message to the database. E.g. Process some special command format, filter bad words and send warnings, etc. The method executePreMessageSentPrevent should have the same accessors as executePostMessageSent. I think we should also add the IModify accessor to extends the usage of the apps engine

cuonghuunguyen avatar Nov 24 '20 08:11 cuonghuunguyen

I disagree. Mutating something in this listener should not happen as that goes against the convention. The Prevent suffix was solely intended for preventing a message from being sent and not modifying anything else based upon preventing a message (and the UI doesn't react well to preventing, so this needs some attention). This logic sounds like it should go into the other preMessageSent ones and not prevent.

But that's simply my opinion. :)

graywolf336 avatar Nov 24 '20 13:11 graywolf336

I do get your point, it makes sense. But I will keep my proposal :D, there will be many things we could do with this change. E.g: Kick a member out of the room if he says offensive words.

cuonghuunguyen avatar Nov 25 '20 08:11 cuonghuunguyen

Re-open since there would be huge number of usecases it can support

cuonghuunguyen avatar Jun 21 '22 15:06 cuonghuunguyen