← All plugin changes

sm-chat-plugin 0.1.5

v0.1.51 min readPlugins

Highlights

A host application can now refuse a chat message before it is stored. Listen for the new MessageSaving event and return a contracts.Rejection, and the client gets the usual 422 validation answer for that field.

Added

  • events.MessageSaving (event name golem15.chat.message.saving) fires before the write transaction when a message is sent, replied to or edited. It carries the conversation, the actor, the root message for replies, the trimmed content and Op (events.OpCreate or events.OpUpdate; MessageID is set on edits).
  • contracts.Rejection{Field, Message}: return it from a listener to refuse the write. The API answers 422 {"error":"Validation failed","errors":{"content":["…"]}} (or the field you name), nothing is stored, and MessageCreated / MessageUpdated do not fire.

Changed

  • Any other error a listener returns aborts the write and keeps the existing opaque 500 answer, so listener internals never reach the client.

Without a MessageSaving listener every route, payload, status and table is unchanged.

Subscribe via RSS