Commit Graph
115 Commits
Author SHA1 Message Date
Lauri Ojansivu 75e260966b Rule emails: pick board members for To from a list with autocomplete.
The send-email action gets a member picker under To: typing filters the
board's active members by user name or full name, and a pick adds
@username to To. Addresses are still typed into To as before. When the
rule runs, each @username becomes that member's current email address,
so the rule - and whoever edits it - holds a user name, never somebody's
address, and a member who changes address is still reached. A @name of
somebody who is not an active member of the board, or has no address, is
dropped rather than sent as text, and nobody is mailed twice.

models/lib/ruleEmailMembers.js holds the parsing, the choices and the
expansion; tests/ruleEmailMembers.test.cjs covers them, non-members,
duplicates, an address with @ inside, and that the picker never reads an
email address. rulesHelper imports it, so the ruleEmailFailure harness,
which runs rulesHelper without require, is given it as it is given
ruleParts. The new strings are English placeholders until the next
translation pass.

Thanks to chenghongxi and xet7 !

Fixes #2435.
2026-10-14 14:30:10 +03:00
Lauri Ojansivu aa48a2b71d Board Settings / Bots: hand cards to external runners, as kanbots does.
Board Settings -> Bots, below Workflow view, is the Rules page's view for
bots: runners on your own server - an AI agent, a CI job, a script - that
the board hands cards to. It is laid out like kanbots in the board's own
theme, Font Awesome and drag and drop: a rail of bots, live runs and
activity; the board's lists as columns, each card with its run's state
(Queued, Running, Waiting for you, Ready to review, Done, Failed, Stopped),
the step it is on and the answers to a question it asked; and a drawer with
the card's thread, Hand to bot, Stop and a reply box. Board admins only,
like the rest of the Rules page, and never a board or public view.

A bot has no rights of its own, like Rules and workflows. WeKan only sends
to it: a bot is an outgoing webhook marked as a bot, subscribed to no board
activity and no reminders, and a dispatch goes through the ordinary webhook
queue - the SSRF guard, its signing token, retries, Sandstorm's Powerbox.
The runner works on the board through WeKan's REST API with its own user's
token and board role, and reports its run at one REST route that needs
write access to the board. Handing over is a board admin's choice, in the
view or with the new Rule action "Hand the card to bot"; an answer or a
reply is the admin's own comment, under their right to comment.

The GitHub- and Gitea-compatible APIs' routes are regular expression
literals now, and an instance board is Trello's "org" level.

The new strings are translated in every locale.

Thanks to xet7 !
2026-10-14 13:39:18 +03:00
Lauri Ojansivu 935e68dfdd GitHub organization import: repositories, issues, releases, Actions, wiki.
Import -> GitHub -> Import a whole GitHub organization makes every
repository of an organization or user its own board, opening in Board View
/ Version Control. Issues go through the ordinary importBoard, as the person
who started the job, with their comments, labels and files. Releases are
cards in a Releases list, their files attached only when chosen. Each
.github/workflows file becomes Rules. The wiki is read from its git
repository with isomorphic-git (1.42.4, pinned), every request through the
SSRF guard and only to github.com: a page is a card in the Wiki list, its
[[links]] point at and are attached to the linked pages' cards, and each
commit that changed it is a dated edit in the card's history, so Restore
brings back an older version. The job shows progress, can be cancelled,
pauses on a restart and stops at a rate limit; the token is kept in memory
only.

Version Control gains Releases and Wiki tabs: the wiki as GitHub shows it,
with the page list, _Sidebar and _Footer, links that stay in the tab, and
each page's history with Restore.

GitHub Actions workflows map to Rules: issue events to triggers, label,
close, reopen, comment, assign and create steps to actions, actions/stale to
an aging rule. Code - builds, tests, scripts - is never run: such a workflow
is a disabled rule with its YAML as the description. WeKan's Rules gain what
they lacked for it: a "commented on" trigger, an "add comment" action written
as the person whose change ran the rule and only where they may comment,
cron schedules in UTC, and a rule description shown on the rule. A disabled
rule no longer fires on a schedule or from its button, which it did.

The new strings are translated in every locale.

Thanks to xet7 !
2026-10-14 12:43:36 +03:00
Lauri Ojansivu eac524380f Add rule triggers for a card moved forward or back.
The reporter puts a card at the bottom of the next list when it moves on and
at the top when it moves back. With only "moved to" and "moved from" a list
triggers, that needs a rule for every pair of lists. "A card is moved forward
to a later list" and "moved back to an earlier list" now fire on any move
between two lists of the board, compared by the lists' order rather than by
the screen, so they also work in right-to-left languages. They are matched
on the rule's own board, like the other trigger kinds
(models/lib/ruleMoveDirection.js).

tests/ruleMoveDirection.test.cjs covers the directions and what has none; a
Playwright case moves cards both ways through the REST API. The RepointBleed
guard counts the new matching path. New text is in English, pending
Transifex.

Thanks to rlach and xet7 !

Fixes #2076.
2026-10-08 12:25:29 +03:00
Lauri Ojansivu f735eba194 Rules: assignee actions, an optional title, and remove-all members that removes them.
#4294 asked for four things. Several triggers and actions, rule variables,
renaming in place and rule import/export were built earlier; two parts were
still missing.

- "I want the assignee to be the creator of the card by default": rules had
  member actions only. Add and Remove assignee actions take a username, a
  {creator}/{assignees}/{members} token, the user who triggered the rule, or
  "*" for every assignee, and write card.assignees. They are durable through
  Sync like the member actions, with the joinAssignee/unjoinAssignee
  activities the assignees hook writes.
- "give a Rule a default name": Add Rule with an empty title showed an
  error, and rules.createRule stored the literal "Rule". The title is now
  optional; the rule is named after its trigger and action ("When ...,
  then ..."), and the rules list renames it in place.

Fixing this found that "Remove all members from the card" iterated the
card's assignees while removing from its members: an earlier fix believed
assignMember wrote assignees, but both definitions in models/cards.js write
members. It removed only members who were also assignees. Remove-all now
iterates card.members, in the ordinary and the durable path, and the guards
that pinned the wrong collection now read models/cards.js to decide.

New text is added in English, pending Transifex.

Thanks to xeruf and xet7 !

Fixes #4294.
2026-10-08 11:31:12 +03:00
Lauri Ojansivu b7084fdc06 A rule's email follows the card to the board the rule's own move took it to.
A rule that moved a card to another board and then sent an email sent nothing:
the email source check refused a card that had left the activity's board, in
both engines. As decided, the email now reads the card on the destination
board, but only when this run of the rule made the move, the destination
opted into Sync effects, and the card is still there. The ordinary engine
remembers its run's own move (RulesHelper.emailActivity), durable Sync proves
it from a saved move of the same plan (ruleEmailActivity, ruleCardNow) and
rechecks it before sending. The stored source binding (version 6) records the
board the card left. Any other card off the board is refused as before, and
an email may now follow a move to another board in a durable plan.

Tests: binding positive and negative cases, a shape guard that nothing else
can claim a followed move, and a server test of both engines that sends once
from the destination and refuses a card nobody's run moved, a move to another
board, and a destination that opted out.

Thanks to xet7 !
2026-10-03 14:26:15 +03:00
Lauri Ojansivu 509f1d97fc Refuse a rule naming another board's trigger, and match rules on their own board (RepointBleed sibling).
Reviewing the legacy direct Rules writes: a board admin of their own board
could save a rule that named a trigger of a board they do not administer.
Only that board's own rules run on its activities, but the matcher took a
trigger's rule from Trigger.getRule() - whichever rule named it first - so
the other board's own rule could silently stop running. The matcher now
looks up the trigger's rule on the activity's board, and a DDP insert or
update of a rule naming another board's trigger is refused and recorded in
Admin Panel / Problems under RepointBleed (no client names one: the rule
editor creates the trigger on the rule's board first).

Tests: tests/repointBleed.test.cjs (the decision for insert, $set,
$addToSet and $push, the negatives, and the matcher's source), and a server
test that, without the change, accepted the foreign rule and lost the
victim board's rule.

Thanks to xet7 !
2026-10-03 10:26:48 +03:00
Lauri Ojansivu acb2c0786a Resolve a rule's later move, sort, move-all and archive on the board its card went to.
As decided on 2026-10-03, after a rule moved its card to another board, a
later action that names the rule's own board works where the card is now,
in the ordinary engine and in durable Sync alike:

- RulesHelper.ruleBoards gives the board the card is on and the board an
  action works on. A move to the top or bottom, a sort and a move-all
  resolve their list and swimlane names there; the write-access check
  covers that board. Before this, a move to "*" after a move to another
  board took the card's new list and swimlane but the old board, leaving
  the card split across two boards.
- The durable move, sort, move-all and archive commands find the card
  through ruleCardNow and save the board it is on as `onBoard`, written
  only when it is not the plan's, so every command saved before still
  validates; the archive's cascade takes the children on that board.
- These actions may now follow a move to another board, so such a plan
  stays durable. An email still may not, nor a second move to yet another
  board.

The archive reservation and follower guards follow the decision; the
cross-board move test now expects sorting and archiving to follow and
refuses an email instead, and a new server test runs the whole chain
durably and with the ordinary engine on a twin card, with the same result.

Thanks to xet7 !
2026-10-03 09:44:45 +03:00
Lauri Ojansivu 9cc42caac9 Make rule moves to another list or swimlane, and move-all, durable on the card's own board.
The rule stage's guard now accepts the card where a saved move of the
SAME rule plan put it (maintainer decision of 2026-10-02), so the rule's
later actions act on the moved card once. Each move is a saved command
with Card.move's effects: the update, the position History row, the
legacy undo row, the attachments' placement and the moveCard activity.
moveAllCardsInList saves one unit per card. Moves, copies and links to
another board stay on the direct path.

Thanks to xet7 !
2026-10-02 17:53:05 +03:00
Lauri Ojansivu 4764b8aa42 Run the addSwimlane rule action through durable Sync.
An addSwimlane rule now has a saved command: the title is resolved once
by RulesHelper.ruleSwimlaneTitle, the swimlane is inserted once under an
id derived from the rule invocation, and the insert hook's
createSwimlane activity is written once, by a derived id, by the command
itself. A swimlane activity has no card, and WeKan's durable activity
delivery is keyed by a card, so that activity is delivered the way every
board-level activity is; what the command guarantees is that the
swimlane and its activity each exist exactly once across replays.

The stored-rule tests now use moveAllCardsInList as their example of an
action with no durable adapter.

Thanks to xet7 !
2026-10-02 17:14:15 +03:00
Lauri Ojansivu 044454e6d0 Run the linkCard rule action through durable Sync on the card's own board.
A linkCard rule that links onto the card's own board now has a saved
command: the linked card is built once as Card.link builds it (a copy
without id and labels, of type cardType-linkedCard pointing at the
original), under an id derived from the rule invocation so a replay
inserts it once, and its creation activity is saved and delivered
durably. The target is resolved by RulesHelper.linkCardTarget, which the
ordinary action now uses too. A link to another board keeps the board
on direct Sync.

Thanks to xet7 !
2026-10-02 17:11:47 +03:00
Lauri Ojansivu d2629161fe Run the createCard rule action through durable Sync.
A createCard rule now has a saved command. Its list, swimlane and title
are resolved once by RulesHelper.createCardTarget - which the ordinary
action uses too, so the two cannot drift - and the new card's id is
derived from the rule invocation, so a replay inserts it once. The
creation hook's createCard activity is known before the insert and is
saved with the command, then delivered durably, which runs the new
card's own rules. A target that does not exist is refused, as the
ordinary insert fails at its activity.

Thanks to xet7 !
2026-10-02 16:58:24 +03:00
Lauri Ojansivu d8c904b94a Run the sortList rule action through durable Sync.
A sortList rule re-sorts the cards of the rule card's list, or a named
list on the same board, and gives each card its index as its sort; the
hook records one position History row per changed card and there is no
activity. It now has a saved command: the order is decided once, by the
same sort keys the ordinary action uses (moved to the pure
models/lib/ruleSortList.js so the two cannot drift), and each changed
card is a unit written conditionally on its saved sort with its planned
position row. Replays change nothing more.

Thanks to xet7 !
2026-10-02 16:55:19 +03:00
Lauri Ojansivu d69cde2ecf Run the addChecklistWithItems rule action through durable Sync.
The checklist lifecycle command now also covers addChecklistWithItems:
the checklist and one item per comma-separated title, both with ids
derived from the rule invocation so a replay inserts them once. After
the inserts it records, from the stored documents and in the order the
hooks write them, the checklist's activity and History row and then each
item's addChecklistItem activity and 'added' row. The item hooks are
deferred only for items of the checklist the command names. The item
titles are resolved by the same RulesHelper call the ordinary action
uses.

Thanks to xet7 !
2026-10-02 16:52:15 +03:00
Lauri Ojansivu 21d7848d47 Run rule checklist creation and removal through durable Sync.
addChecklist and removeChecklist rule actions now have saved commands,
like the other durable rule actions. addChecklist inserts a checklist
whose id is derived from the rule invocation, so a replay inserts it
once, and records the hook's addChecklist activity and History lifecycle
row from the document as it was stored. removeChecklist saves every
checklist the ordinary selector matches, one unit each, and for each
writes the removeChecklist activity before the removal and the 'removed'
History row after it, refusing a checklist that changed since capture.
The checklist hooks are deferred only for the checklist a command names.

Thanks to xet7 !
2026-10-02 15:40:57 +03:00
Lauri Ojansivu c63d909c81 Close the RuleBleed legacy-action sibling: an action without a board acts on its own board.
A legacy or imported rule action with no boardId made the move and link actions
look up lists and swimlanes with { boardId: undefined }, which matches by title
on any board, while the cross-board check compared against the activity's
board. performAction now gives such an action the activity's board once, before
any lookup or check; the cached document is not changed.

Thanks to xet7 !
2026-10-02 11:28:21 +03:00
Lauri Ojansivu a8e836efd3 Fix BypassBleed's rule-loop denial of service: a chain of rules started by rules stops at a depth limit.
BypassBleed (2022) reported, besides the authentication bypass, that two rules
undoing each other - label added: remove it; label removed: add it - recursed
without end: a rule's action writes a card, the write inserts an activity, and
the activity runs the rules again in the same awaited chain. That part was
never fixed. Rule runs started by a rule are now counted in async context, and
a chain deeper than five stops and is reported to Problems as BypassBleed
(detected, medium: usually an honest mistake). Separate activities are not
affected. The test runs the real executeRules with the reported loop;
BypassBleed moves from the recorded gaps to guarded and from pending to keyed;
two tests that load RulesHelper in a vm get the guard as a pass-through.

Thanks to xet7 !
2026-10-02 11:13:18 +03:00
Lauri Ojansivu f02da1bfd2 Fix RepointBleed: board-owned rule, webhook and custom-field documents cannot be moved to another board.
Triggers, Actions, Rules and Integrations were allowed to a board admin of the
board the document was on BEFORE an update; nothing refused the update itself
changing boardId. Any registered user, admin of a board they created, could
move a rule trigger to '*' or unset its board - which the rule matcher matched
on every board - and have a send-email action mail them cards, comments and
attachments from every private board; or move a webhook integration onto a
private board and receive its activity, or rewrite its comments through a
two-way hook. Custom fields accepted a board list if the caller could write to
ANY board in it, so a field could be planted on (or pulled from) a board
without access; comment reactions could be moved onto another comment.

A shared deny rule now refuses any client update that changes those
documents' board, custom fields need write access on every board they are put
on or taken off, and the rule matcher runs a rule only for activity on its own
board. Refusals record RepointBleed in Admin Panel -> Problems (high: no client
changes these fields). Unit, negative (every board-owned permissions file) and
browser tests.

Thanks to xet7 !
2026-10-02 10:34:38 +03:00
Lauri Ojansivu 0395989d01 Make the member rule actions durable in Sync.
addMember and removeMember join the durable card-field actions. The people
are resolved at capture exactly as performAction resolves them - the acting
user for the #2522 option, username tokens through buildRuleVars (#4294),
and the card's assignees for "remove every member" (#2674) - by a new
RulesHelper.resolveMemberTargets beside it, and saved with their usernames,
so a replay acts on the same people. The ordinary action's one $addToSet or
$pull per person becomes one planned change of `members`, with a joinMember
or unjoinMember activity for each person who really joined or left, as the
members hook writes it, and one members History row.

The new helper phrases its conditions so the source guards that locate
performAction's member branch still find it, and the recording-isolation
test now uses assignees as its example of a field that is never deferred.
Unit tests cover resolution being saved, joins and leaves, nobody resolved
and tampered targets; the full-app durable Sync test adds a member to every
created card through a rule - one joinMember activity and one members
History row. 565 server tests pass.

Thanks to xet7 !
2026-09-30 12:09:24 +03:00
Lauri Ojansivu b1dbea2152 Accept rule variables in trigger values.
A trigger's list, swimlane, title, checklist and user fields may now use the
variables actions already resolve - {creator}, {assignees}, {members},
{customField:Name} and the rest - read from the card when the rule is
checked: "when a card is moved to the list named in its {customField:Stage}".
Such a value never equals what an activity carries, so the rule engine now
also fetches this board's triggers that hold a token and resolves them; every
other field keeps the ordinary exact-or-wildcard rule. People tokens match any
one of the named users, "by {assignees}" is kept as typed and compared by
username, and an unknown token stays literal. The editor explains this in a
new hint, English pending Transifex.

Thanks to xet7 !
2026-09-29 16:09:49 +03:00
Lauri Ojansivu 69eeb00c84 Let a rule have several triggers (any fires it) and several actions (in order).
Maintainer decision for #4294 and #2953: a rule keeps its own trigger and
action and may add up to ten more of each. It fires when any of its
triggers fires - once per activity, even when several match - and runs its
actions in order, its own first. Rule details lists the extra parts with
Add another trigger / Add another action and Remove; the new
rules.addPart/removePart methods keep the board-admin and cross-board
destination checks of rules.createRule and refuse a button as an extra
trigger.

Ordinary, scheduled and button rules, the durable Sync rule plan, rule
History (snapshot, part edits and restore), deletion, board copy, WeKan
export/import, the rules JSON export/import, the REST representation and
the admin rules report all handle every part. Two rule-engine test
harnesses now receive the new helpers they evaluate.

New strings are in en.i18n.json, pending translation.

Thanks to xet7 !

Fixes #2953,
2026-09-29 14:34:18 +03:00
Lauri Ojansivu a918559939 Resolve people and custom-field variables in rule action values.
Maintainer decision: rule actions reuse the email {token} syntax.
{creator}, {assignees} and {members} name the triggering card's people -
usernames in text, email addresses in the send-email recipient, where
entries without an address are dropped - and {customField:Name} reads the
displayed value of a custom field, excluding admin-only fields. Member
actions accept a token that names several people and act on each; list and
swimlane names of move actions are resolved too. Literal values behave
exactly as before and unknown tokens stay literal.

The email action shows the new tokens in a second hint, English pending
Transifex.

Thanks to xet7 !
2026-09-29 14:02:14 +03:00
Lauri Ojansivu 5513254086 Include authorized target-board comments in linked-board rule emails
Discover comment owners before reading prose, enforce card and assigned-only access, and retain each included source chain for stored dispatch checks. Reuse public comment rendering without exporting target checklists or files; reject oversized captures instead of truncating.

Thanks to kabi178, bbyszio and xet7 !
2026-09-28 21:07:14 +03:00
Lauri Ojansivu 5bd348a4b9 Include linked-board wrapper content with shared email policies
Reuse ordinary Details rendering for explicitly local fields, including custom-field visibility and definition fingerprints, public names, notes, locations and authorized relationships. Persist related-source evidence in the existing email binding.

Thanks to kabi178, bbyszio and xet7 !
2026-09-28 21:00:16 +03:00
Lauri Ojansivu 032e0db794 Include scoped local linked-card details in rule emails
Separate wrapper placement, persisted timers and visible Scrum metadata from authorized source content. Recheck local access, link identity and Scrum visibility before returning the snapshot.

Thanks to kabi178, bbyszio and xet7 !
2026-09-28 20:42:34 +03:00
Lauri Ojansivu 027d399cb2 Include attachment presentation metadata in rule emails
Describe captured filenames, actual sizes, MIME types, cover status, upload dates and public uploader names. Recheck card access and cover state after metadata reads and reject deleted cards or foreign attachment rows.

Thanks to kabi178, bbyszio and xet7 !
2026-09-28 20:29:08 +03:00
Lauri Ojansivu 2a632445b2 Include authorized converted-subtask references in rule emails
Share related-source resolution between Details and checklist discussion. Retain reference evidence for stored messages even when Details is disabled, and omit inaccessible targets.

Thanks to kabi178, bbyszio and xet7 !
2026-09-28 20:26:06 +03:00
Lauri Ojansivu b1b126fb0c Bind stored email details to related sources and field policies
Resolve related link titles through current readable sources and retain their chains in immutable command evidence. Recheck related access, admin rights and custom-field definitions before stored dispatch. Refuse legacy Details snapshots without related evidence.

Thanks to kabi178, bbyszio and xet7 !
2026-09-28 20:23:01 +03:00
Lauri Ojansivu d99641d8ed Include visible Scrum card metadata in rule email details
Resolve sprint and release names within the source board and recheck references after preparation. Persist Scrum disclosure flags with source evidence for stored sends.

Thanks to kabi178, bbyszio and xet7 !
2026-09-28 20:11:49 +03:00
Lauri Ojansivu 6e4032b69c Bind stored rule emails to their authorized source chain
Capture versioned source evidence with immutable mail and verify its topology and current access before dispatch. Keep legacy commands readable without authorizing an unbound retry.

Thanks to kabi178, bbyszio and xet7 !
2026-09-28 19:57:36 +03:00
Lauri Ojansivu 479f01d57e Resolve authorized linked sources for rule email content
Use live source card data across email text, details, discussion and files. Resolve linked-board display fields without including unrelated source-board cards. Recheck each link and its permissions after preparation, and reject cycles, missing sources or retargeted links.

Refuse linked stored Sync commands until durable source-chain bindings exist, including during dispatch of previously captured commands. Fifty-seven Node suites pass without skips, with real MongoDB and native MailComposer; local SMTP browser scenarios pass.

Thanks to kabi178, bbyszio and xet7 !
2026-09-28 19:51:34 +03:00
Lauri Ojansivu c06b429765 Include authorized card details in rule emails
Render dates, placement, labels, people, custom-field display values, notes and readable relationships behind an opt-in Details checkbox. Recheck source and related access, admin-only field policy and field definitions; do not serialize account secrets or stale linked-source snapshots.

Thirty-six Node suites and two local SMTP browser scenarios pass. Linked-source details and specialized fields remain open under #2713.

Thanks to kabi178, bbyszio and xet7 !
2026-09-28 19:44:33 +03:00
Lauri Ojansivu 05080fc02e Include checklists and public comments in rule emails
Offer an independent opt-in choice, render checklist completion and chronological comments, exclude deleted or foreign content and private webhook state, and recheck access after child reads. Bound output without silent truncation.

Verify 35 Node suites and two local SMTP browser scenarios, including disabling the option. Other card metadata remains open under #2713.

Thanks to kabi178, bbyszio and xet7 !
2026-09-28 19:39:51 +03:00
Lauri Ojansivu 846f190690 Send authorized card attachments with email rules
Add an opt-in native checkbox, read live triggering-card files through the storage strategy, recheck source access and attachment metadata after reads, and preserve byte snapshots through email localization and transport.

Verify filesystem and GridFS MIME delivery with local SMTP capture, soft deletion, missing-file failures, keyboard selection, permission changes and durable attachment integrity. Full card-content rendering remains open in #2713.

Thanks to kabi178, bbyszio and xet7 !
2026-09-28 19:35:19 +03:00
Lauri Ojansivu 998b96bf91 Add authorized Copy Card rule actions with destination pickers
Reuse ordinary card copying, preserve the source, validate destination placement and current write access, and stop recursive copy chains while allowing independent events.

Verify automatic and manual copies, checklists and comments, revoked access, forged destinations and same-board recursion in Chromium. All 29 rule Node suites pass.

Thanks to javen9881, phaseshift3r, gugmt15 and xet7 !

Fixes #4160,
Fixes #3235,
2026-09-28 19:25:40 +03:00
Lauri Ojansivu 319173291e Capture stored rule mail through shared variable and localization preparation 2026-09-28 15:44:05 +03:00
Lauri Ojansivu b5d7910b7a Propagate rule email failures before acknowledging scheduled execution 2026-09-28 15:30:48 +03:00
Lauri Ojansivu 569c2c61b3 Await rule date label and link writes before continuing execution 2026-09-28 15:29:15 +03:00
Lauri Ojansivu ca7863722a Emit custom-field activities after successful card writes
Compare saved custom-field values by identity for array, dotted and assignment updates. Suppress no-op and failed writes, preserve zero and false, and evaluate advanced-filter rules using boardIds-scoped definitions.

Thanks to xet7.
2026-09-28 01:38:20 +03:00
Lauri Ojansivu 64123a603a Bind manual rule execution to a writable board and its card
Check write capability and authoritative card board before button dispatch and again in the shared action dispatcher. Board buttons without a card remain supported. Record denied contexts in bounded Problems summaries.

Role and boundary decisions plus dispatcher inventory and existing rule suites pass. Browser regression syntax-check passes; live execution pending.

Thanks to Wenhao Wu, Southeast University and xet7 !
2026-09-14 11:53:05 +03:00
Lauri Ojansivu 952679f9c3 CHANGELOG: close the list/swimlane link issue (#1089).
Thanks to xet7 and xet7 !

Fixes #1089,
2026-09-10 21:01:12 +03:00
Lauri Ojansivu b925b21708 Restore the "send email" rule action's automatic description line (#2713).
Concurrent edits to server/rulesHelper.js's sendEmail block in this shared
checkout dropped the "Description: ..." footer line added earlier for
#2713 (the description sits right next to the pre-existing "Card:"/"Link:"
lines from #3301, so it merged awkwardly). Restoring it: the sendEmail
action now appends the card's description automatically again, same as its
title and link, guarded the same way (only when non-empty).

Thanks to kabi178 and xet7 !
2026-09-10 20:43:34 +03:00
Lauri Ojansivu b8a6de1c89 Let a rule's trigger/action be edited in place, and email the card's description too.
#2713 asked for two things.

Editing a rule used to mean delete it and rebuild it from scratch, losing
its position and its identity. rulesList's rule row gets a second "Edit
trigger/action" button next to the existing title-rename pencil, opening
the same trigger/action wizard used to create a rule (rulesMain.js /
rulesTriggers / rulesActions and the board/card/checklist/mail action
templates), pre-filled with the rule's current title. A new server method,
rules.updateRule (server/rulesButton.js), mirrors rules.createRule's
authorization and cross-board destination checks but REPLACES the existing
trigger/action documents in place (full-document update by their existing
_id, not remove+insert), so the rule keeps its own _id, and its trigger/
action keep theirs, across an edit. Every action-template click handler
that used to call rules.createRule or insert Triggers/Actions/Rules
directly now goes through one shared helper,
client/components/rules/rulesSaveHelper.js, which picks create vs. update
based on whether the wizard was opened to edit an existing rule.

The "send an email" rule action already appended the card's title and a
link to it automatically (#3301), even when the user's own template used
none of the {card}/{cardLink} tokens; it did not do the same for the card's
description. server/rulesHelper.js now appends "Description: ..." to the
footer alongside the existing title/link lines, using the vars.description
value buildRuleVars already computed.

Actually attaching the card's FILE ATTACHMENTS to the outgoing email is
deferred - see CHANGELOG TODO Later. Every WeKan email today goes through
either Meteor's `Email.sendAsync`/`EmailLocalization.sendEmail`, which take
{ to, from, subject, text }, with no `attachments` parameter anywhere in
this codebase's call sites; wiring a real file through would need the
mailer wrapper itself to grow attachment support and code to read the file
back out of whichever storage backend (local disk / GridFS / S3) holds it,
which is mailer-level scope well past this rule action.

tests/ruleUpdateInPlace.test.cjs pins rules.updateRule's authorization,
its RuleBleed cross-board guard, and - the part that actually makes it an
edit rather than a second create - that it keeps the rule/trigger/action
_ids stable, including a logic-level round trip against a small in-memory
mock proving a changed actionType does not leave the old type's fields
behind. tests/ruleEmailIncludesDescription.test.cjs pins the new
description line, guarded the same way the existing title/link lines are
(only appended when non-empty).
tests/ruleCardActionSchema.test.cjs (#6630's guard, that desc lives on the
Action document and never leaks onto the Rule document) is updated for the
new saveRuleTriggerAction call shape.

Thanks to kabi178 and xet7 !
2026-09-10 20:38:21 +03:00
Lauri Ojansivu 16c8f425d0 Let a rule's trigger/action be edited in place, and email the card's description too.
#2713 asked for two things.

Editing a rule used to mean delete it and rebuild it from scratch, losing
its position and its identity. rulesList's rule row gets a second "Edit
trigger/action" button next to the existing title-rename pencil, opening
the same trigger/action wizard used to create a rule (rulesMain.js /
rulesTriggers / rulesActions and the board/card/checklist/mail action
templates), pre-filled with the rule's current title. A new server method,
rules.updateRule (server/rulesButton.js), mirrors rules.createRule's
authorization and cross-board destination checks but REPLACES the existing
trigger/action documents in place (full-document update by their existing
_id, not remove+insert), so the rule keeps its own _id, and its trigger/
action keep theirs, across an edit. Every action-template click handler
that used to call rules.createRule or insert Triggers/Actions/Rules
directly now goes through one shared helper,
client/components/rules/rulesSaveHelper.js, which picks create vs. update
based on whether the wizard was opened to edit an existing rule.

The "send an email" rule action already appended the card's title and a
link to it automatically (#3301), even when the user's own template used
none of the {card}/{cardLink} tokens; it did not do the same for the card's
description. server/rulesHelper.js now appends "Description: ..." to the
footer alongside the existing title/link lines, using the vars.description
value buildRuleVars already computed.

Actually attaching the card's FILE ATTACHMENTS to the outgoing email is
deferred - see CHANGELOG TODO Later. Every WeKan email today goes through
either Meteor's `Email.sendAsync`/`EmailLocalization.sendEmail`, which take
{ to, from, subject, text }, with no `attachments` parameter anywhere in
this codebase's call sites; wiring a real file through would need the
mailer wrapper itself to grow attachment support and code to read the file
back out of whichever storage backend (local disk / GridFS / S3) holds it,
which is mailer-level scope well past this rule action.

tests/ruleUpdateInPlace.test.cjs pins rules.updateRule's authorization,
its RuleBleed cross-board guard, and - the part that actually makes it an
edit rather than a second create - that it keeps the rule/trigger/action
_ids stable, including a logic-level round trip against a small in-memory
mock proving a changed actionType does not leave the old type's fields
behind. tests/ruleEmailIncludesDescription.test.cjs pins the new
description line, guarded the same way the existing title/line lines are
(only appended when non-empty).
tests/ruleCardActionSchema.test.cjs (#6630's guard, that desc lives on the
Action document and never leaks onto the Rule document) is updated for the
new saveRuleTriggerAction call shape.

Thanks to jvavassori and xet7 !
2026-09-10 20:37:56 +03:00
Lauri Ojansivu e643f0da71 Add a direct card link and {card}/{cardLink}/{list}/{board}/{member}
template tokens to the Rules "send an email" action.

The "send an email" rule action sent a bare message with no reference to
the card that triggered it - no title, no link, and no way to pull in the
list, board or triggering member. performAction() already builds a
ruleVars map and substituteVars() already replaces {name} tokens in email
subject/body (added for #2475), so this extends that existing mechanism
rather than building a new one:

- {cardLink} resolves via Card.absoluteUrl() (models/lib/cardUrl.js), the
  same helper card activity notification emails already use, so no new
  URL-building code is needed.
- {member} resolves the activity's memberId (the member added/removed/
  etc.) falling back to the acting user when the activity records none.
- {card}/{list}/{board} are short aliases of the existing cardname/
  listname/boardname/username variables, documented next to the email
  fields via a new r-email-vars-hint hint text so the tokens are
  discoverable without external docs.
- Independently of any template the user configures, the card's title and
  link are now always appended to the sent email body, so #3301's core ask
  (a direct link to the card) holds even for a rule someone set up before
  this change with no tokens at all.

substituteVars() moves out of server/rulesHelper.js into a new pure
models/lib/ruleVarsSubstitute.js so it can be unit tested directly, the
way models/lib/cardUrl.js next to it already is; tests/ruleEmailVars.test.cjs
covers token substitution (including case-insensitivity, unknown tokens
left as literal text, and malformed braces not being mistaken for tokens),
the automatic card-link footer, and that the new hint text is present and
translated.

Thanks to vossilius and ivan-paleo and xet7 !

Closes #3304,
Closes #3301,
2026-09-10 20:02:54 +03:00
Lauri Ojansivu 1c97bbac85 Add a "Remove all labels" rule action.
WeKan's IFTTT-style Rules already had per-label "add label X" / "remove
label X" card actions (models/cards.js addLabel/removeLabel, wired in
server/rulesHelper.js and the label dropdown in
client/components/rules/actions/cardActions.jade/.js). Removing every
label from a card required one "remove label" action per label.

Card.removeAllLabels() sets labelIds to an empty array in one update
(a card with no labels is a no-op), and a new "Remove all labels" rule
action (actionType 'removeAllLabels', no label-selection sub-field)
calls it from a new dropdown entry next to the existing label actions,
mirroring the existing "Remove all members" action's wiring.

Thanks to Southclaws and xet7 !

Closes #3432,
2026-09-10 19:59:11 +03:00
Lauri Ojansivu dffe85cce4 Block unauthorized cross-board rule actions
Validate automation destinations before storing a rule and again before executing legacy or imported move, link, and bulk-move actions. Record denied attempts through the bounded RuleBleed canary.\n\nThanks to crypto-nidh and xet7 !
2026-08-29 09:43:23 +03:00
Lauri Ojansivu e1ebe978b9 Rules: 'remove all members' action now removes the card's assignees (#2674).
The rule member actions operate on a card's ASSIGNEES: addMember calls card.assignMember() and removeMember calls card.unassignMember() (both write card.assignees). The 'remove all' branch (username === '*') however iterated card.members -- a different collection -- so it unassigned nobody a rule had assigned and 'remove every member' silently did nothing. Iterate the card's assignees (card.getAssignees()) instead, snapshotting the ids first since unassignMember pulls from that same array. The single-user add/remove were already symmetric (the earlier #2674 fix that made them assign/unassign); this completes it for the wildcard case.

Tests: tests/ruleRemoveMemberAction.test.cjs (6 checks) pins the add/remove symmetry, that the '*' branch reads assignees (not card.members) and still unassigns each, and the defensive skip for an unresolved username.

Thanks to sfahrenholz and xet7 !

Fixes #2674,
2026-07-22 10:15:50 +03:00
Lauri Ojansivu e6b001320c Fix rules: action never executes because trigger match required omitted fields.
A moveCard trigger has no oldListName (the wizard chooses a destination
list, not a source), but findMatchingRules built the trigger query with
{ oldListName: { $in: [value, '*'] } }. Mongo's $in does not match a
document that is MISSING the field unless null is in the list, so the
trigger never matched and the rule's action silently never ran, with no
error. Add null to the match list for every field (a $in with null also
matches a missing field), exactly like the cardTitle handling (#2345).

Thanks to xet7 !

Fixes #6491.
2026-07-20 16:00:56 +03:00
Lauri Ojansivu 25d33cec36 Fix #2345 #2674 #574: rules card title filter, rules REST API, api docs;
Sandstorm username races.

- #2345: the Card Title Filter is now SAVED by every board trigger
  builder (a trigger doc missing the field could never satisfy the
  matcher's $in - those rules fired for nothing), SHOWN in the rule
  details, and ENFORCED for archive/restore triggers by resolving the
  title from the card when the activity lacks it; legacy field-less
  triggers keep matching; the filter popup prefills its current value.
- #2674: rules created via POST/PUT /api/boards/:boardId/rules never
  fired - missing matching fields are now normalized to '*' wildcards
  and trigger/action types validated; the addMember/removeMember rule
  actions no longer crash on unresolvable usernames or member-less
  cards and their writes are awaited. New docs/API/Rules.md (endpoints,
  matching fields, wildcard semantics, the exact two-rule
  add-on-move-to/remove-on-move-from workflow), linked from REST-API.md;
  api.py help now lists the rule commands with the same example.
- #574: Sandstorm unique-username generation probes case-insensitively
  (anchored, regex-escaped) and retries the next number when a
  concurrent insert wins the unique-index race, instead of aborting the
  login hook with E11000.

Tests: tests/rulesCardTitleFilter.test.cjs (12),
tests/rulesApiTriggerNormalize.test.cjs (19),
tests/sandstormUsername.test.cjs (11) - positive and negative cases.

Thanks to InfoSec812, sfahrenholz, mitar and xet7.
2026-07-17 03:36:50 +03:00