mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
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,