Skip to content

feat(mattermost): add edit and delete message actions#25295

Open
Luna2026-a11y wants to merge 10 commits intoopenclaw:mainfrom
Luna2026-a11y:feat/mattermost-edit-delete
Open

feat(mattermost): add edit and delete message actions#25295
Luna2026-a11y wants to merge 10 commits intoopenclaw:mainfrom
Luna2026-a11y:feat/mattermost-edit-delete

Conversation

@Luna2026-a11y
Copy link
Copy Markdown

@Luna2026-a11y Luna2026-a11y commented Feb 24, 2026

Summary

Adds patchMattermostPost() and deleteMattermostPost() to the Mattermost client, and wires them as edit and delete actions in the channel plugin message action adapter.

What this enables

  • Edit messages via the message tool (action=edit) — foundation for block-streaming edit-in-place (progressive message rendering like Telegram/Discord)
  • Delete messages via the message tool (action=delete)

API endpoints used

  • Edit: PUT /api/v4/posts/{post_id}/patch (partial update)
  • Delete: DELETE /api/v4/posts/{post_id}

Files changed

  • extensions/mattermost/src/mattermost/client.ts — add patchMattermostPost() and deleteMattermostPost()
  • extensions/mattermost/src/channel.ts — register edit and delete in listActions, supportsAction, and handleAction

Testing

  • Tested against a live Mattermost 10.x instance: create → edit → delete cycle works correctly
  • Bot requires edit_post / delete_post permissions (standard bot permissions)

Notes

This is a stepping stone toward full block-streaming support on Mattermost, bringing it closer to feature parity with the Telegram and Discord plugins.

Greptile Summary

Added edit and delete message functionality to the Mattermost plugin by implementing patchMattermostPost() and deleteMattermostPost() in the client, and wiring them through the channel message action adapter.

Changes:

  • Added patchMattermostPost() function supporting partial updates (message, props, fileIds)
  • Added deleteMattermostPost() function for post deletion
  • Registered edit and delete actions in listActions() and supportsAction()
  • Implemented action handlers that validate params, resolve account config, and call the API functions
  • Used standard Mattermost API endpoints (PUT /posts/{id}/patch, DELETE /posts/{id})

Architecture:

  • Follows existing pattern from react action handler (account resolution, validation, error handling)
  • Accepts both messageId and postId parameter names for flexibility
  • Returns structured results with content and details

The implementation is straightforward and brings Mattermost closer to feature parity with Telegram and Discord plugins.

Confidence Score: 4/5

  • This PR is safe to merge with low risk
  • Clean implementation following established patterns. The code correctly validates required parameters, handles account resolution, and uses proper error handling. One minor style suggestion about empty message validation, but this won't cause runtime errors since the Mattermost API will reject empty edits if they're not allowed.
  • No files require special attention

Last reviewed commit: e3df5fa

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

@openclaw-barnacle openclaw-barnacle bot added channel: mattermost Channel integration: mattermost size: S labels Feb 24, 2026
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +74 to +80
const message =
typeof (params as any)?.message === "string"
? (params as any).message
: typeof (params as any)?.text === "string"
? (params as any).text
: "";
if (!message) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty message is allowed but might cause API errors

The code allows empty strings for the message parameter, but Mattermost API typically requires non-empty message text. If params.message or params.text is an empty string, it will pass the empty string check but could fail at the API level.

Compare with Discord (line 171 in src/channels/plugins/actions/discord/handle-action.ts): requires message with required: true
Compare with Telegram (line 161 in src/channels/plugins/actions/telegram.ts): requires message with required: true, allowEmpty: false

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/mattermost/src/channel.ts
Line: 74-80

Comment:
empty message is allowed but might cause API errors

The code allows empty strings for the `message` parameter, but Mattermost API typically requires non-empty message text. If `params.message` or `params.text` is an empty string, it will pass the empty string check but could fail at the API level.

Compare with Discord (line 171 in `src/channels/plugins/actions/discord/handle-action.ts`): requires message with `required: true`
Compare with Telegram (line 161 in `src/channels/plugins/actions/telegram.ts`): requires message with `required: true, allowEmpty: false`

How can I resolve this? If you propose a fix, please make it concise.

@openclaw-barnacle
Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added the stale Marked as stale due to inactivity label Mar 3, 2026
@mukhtharcm mukhtharcm self-assigned this Mar 14, 2026
@mukhtharcm mukhtharcm force-pushed the feat/mattermost-edit-delete branch 2 times, most recently from 6350dbd to b5650e4 Compare March 16, 2026 00:52
@openclaw-barnacle openclaw-barnacle bot added commands Command implementations size: M and removed size: S labels Mar 16, 2026
@mukhtharcm mukhtharcm force-pushed the feat/mattermost-edit-delete branch from b5650e4 to 3e7598c Compare March 16, 2026 01:50
@openclaw-barnacle openclaw-barnacle bot added channel: signal Channel integration: signal and removed commands Command implementations labels Mar 16, 2026
@mukhtharcm mukhtharcm force-pushed the feat/mattermost-edit-delete branch from 54075f1 to 4ec6fb5 Compare March 16, 2026 08:20
@openclaw-barnacle openclaw-barnacle bot removed the channel: signal Channel integration: signal label Mar 16, 2026
@mukhtharcm mukhtharcm force-pushed the feat/mattermost-edit-delete branch from 4ec6fb5 to bb067c0 Compare March 16, 2026 08:24
Luna and others added 10 commits March 16, 2026 08:26
Add patchMattermostPost() and deleteMattermostPost() to the Mattermost
client, and wire them as 'edit' and 'delete' actions in the channel
plugin's message action adapter.

This enables:
- Editing bot messages via the message tool (action=edit)
- Deleting bot messages via the message tool (action=delete)
- Foundation for block-streaming edit-in-place (progressive message
  rendering like Telegram/Discord)

Uses PATCH /api/v4/posts/{post_id}/patch for edits and
DELETE /api/v4/posts/{post_id} for deletions.

Tested against a live Mattermost 10.x instance.
@mukhtharcm mukhtharcm force-pushed the feat/mattermost-edit-delete branch from bb067c0 to 69b8aef Compare March 16, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: mattermost Channel integration: mattermost size: M stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants