Mattermost: several channels, private messages and report author #13

Closed
opened 2026-10-25 22:34:02 +00:00 by Gilles · 0 comments
Owner

Follow-up to #10. The Mattermost channel of an event rule only posts to a single channel. It should also send private messages.

Targets (all combinable, per rule)

  • several channels, replacing the single mattermost_channel_id;
  • several private-message recipients, picked among Mattermost accounts;
  • the report's author, as a private message (checkbox). The author is the actor sent by argus/upload-action ≥ 1.2.0.

Backend

  • EventRule:
    • mattermost_channels: a list of {id, name}, which replaces mattermost_channel_id/_name;
    • mattermost_users: a list of {id, username};
    • mattermost_notify_author: a boolean.
    • A data migration moves the existing single channel into the list.
  • Private messages: the bot opens the direct channel (POST /api/v4/channels/direct, bot + user), then posts the same severity-coloured attachment.
  • Author resolution: the Forgejo login gives the Forgejo email (service token). That email gives the Mattermost user (GET /api/v4/users/email/{email}). If not found, fall back to the same login (GET /api/v4/users/username/{login}). If the author is unknown or missing, that target is reported as skipped; it doesn't fail the delivery.
  • Delivery: still one "Mattermost" delivery per event, but each target is tracked. A retry only resends the targets that failed. The detail summarises everything, e.g. "2 canal(aux), 3 MP, auteur : introuvable".
  • GET /api/mattermost/users/?q=: account search for the picker (bot autocomplete).
  • "Test rule" also sends to the private-message targets; the requesting user stands in for the author.

Frontend

  • Rule form, Mattermost section: channel checkboxes, account search with removable chips, and an "Auteur du rapport (message privé)" checkbox.
  • The rule list summarises the targets.

Tests

  • pytest: migration, several channels, private messages, author resolution (email, then login, then not found), partial retry, user search API.
  • vitest: the form and its payload.
Follow-up to #10. The Mattermost channel of an event rule only posts to a single channel. It should also send private messages. ## Targets (all combinable, per rule) - **several channels**, replacing the single `mattermost_channel_id`; - **several private-message recipients**, picked among Mattermost accounts; - **the report's author**, as a private message (checkbox). The author is the `actor` sent by argus/upload-action ≥ 1.2.0. ## Backend - `EventRule`: - `mattermost_channels`: a list of `{id, name}`, which replaces `mattermost_channel_id`/`_name`; - `mattermost_users`: a list of `{id, username}`; - `mattermost_notify_author`: a boolean. - A data migration moves the existing single channel into the list. - Private messages: the bot opens the direct channel (`POST /api/v4/channels/direct`, bot + user), then posts the same severity-coloured attachment. - Author resolution: the Forgejo login gives the Forgejo email (service token). That email gives the Mattermost user (`GET /api/v4/users/email/{email}`). If not found, fall back to the same login (`GET /api/v4/users/username/{login}`). If the author is unknown or missing, that target is reported as skipped; it doesn't fail the delivery. - Delivery: still one "Mattermost" delivery per event, but each target is tracked. A retry only resends the targets that failed. The detail summarises everything, e.g. "2 canal(aux), 3 MP, auteur : introuvable". - `GET /api/mattermost/users/?q=`: account search for the picker (bot autocomplete). - "Test rule" also sends to the private-message targets; the requesting user stands in for the author. ## Frontend - Rule form, Mattermost section: channel checkboxes, account search with removable chips, and an "Auteur du rapport (message privé)" checkbox. - The rule list summarises the targets. ## Tests - pytest: migration, several channels, private messages, author resolution (email, then login, then not found), partial retry, user search API. - vitest: the form and its payload.
Sign in to join this conversation.
No description provided.