Files
wekan/server/triggersDef.js
T
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

117 lines
3.9 KiB
JavaScript

// Maps each event `activityType` to the trigger fields used to match rules.
// NOTE: two trigger kinds are intentionally NOT listed here because they are not
// driven by activities:
// - 'scheduledTrigger' (time/due/aging) is evaluated by server/scheduledRules.js
// via SyncedCron.
// - 'button' (card/board manual buttons) runs only via the rules.runButton method.
// - 'advancedFilterTrigger' and 'textContainsTrigger' (#2194 "card title/
// description contains {value}") are not exact/wildcard field matches
// either - server/rulesHelper.js re-reads the card's current state and
// evaluates them directly (see cardMatchesAdvancedFilter /
// cardTextContainsMatch) on createCard/a-changedTitle/a-changedDescription.
// - 'moveCardDirection' (#2076 "a card is moved forward / back") compares
// the old and new list's order on each moveCard activity
// (models/lib/ruleMoveDirection.js), so it is matched directly as well.
export const TriggersDef = {
createCard: {
matchingFields: [
'boardId',
'listName',
'userId',
'swimlaneName',
'cardTitle',
],
},
moveCard: {
matchingFields: [
'boardId',
'listName',
'oldListName',
'userId',
'swimlaneName',
'cardTitle',
],
},
archivedCard: {
matchingFields: ['boardId', 'userId', 'cardTitle'],
},
// A comment added to a card (GitHub's issue_comment: created). The comment
// activity names the card, not its list, so a list cannot be matched.
addComment: {
matchingFields: ['boardId', 'userId', 'cardTitle'],
},
restoredCard: {
matchingFields: ['boardId', 'userId', 'cardTitle'],
},
joinMember: {
matchingFields: ['boardId', 'username', 'userId'],
},
unjoinMember: {
matchingFields: ['boardId', 'username', 'userId'],
},
joinAssignee: {
matchingFields: ['boardId', 'username', 'userId'],
},
unjoinAssignee: {
matchingFields: ['boardId', 'username', 'userId'],
},
addChecklist: {
matchingFields: ['boardId', 'checklistName', 'userId'],
},
removeChecklist: {
matchingFields: ['boardId', 'checklistName', 'userId'],
},
completeChecklist: {
matchingFields: ['boardId', 'checklistName', 'userId'],
},
uncompleteChecklist: {
matchingFields: ['boardId', 'checklistName', 'userId'],
},
addedChecklistItem: {
matchingFields: ['boardId', 'checklistItemName', 'userId'],
},
removedChecklistItem: {
matchingFields: ['boardId', 'checklistItemName', 'userId'],
},
checkedItem: {
matchingFields: ['boardId', 'checklistItemName', 'userId'],
},
uncheckedItem: {
matchingFields: ['boardId', 'checklistItemName', 'userId'],
},
addAttachment: {
matchingFields: ['boardId', 'userId'],
},
deleteAttachment: {
matchingFields: ['boardId', 'userId'],
},
addedLabel: {
matchingFields: ['boardId', 'labelId', 'userId'],
},
removedLabel: {
matchingFields: ['boardId', 'labelId', 'userId'],
},
// #2474: "a card's due/start/end/received date is set or changed" triggers.
// These activityTypes ('a-dueAt'/'a-startAt'/'a-endAt'/'a-receivedAt') are
// NOT new - models/cards.js's setDue/setStart/setEnd/setReceived already go
// through server/models/cards.js's Cards.before.update timing-field hook,
// which logs one of these activities (with timeKey/timeValue/timeOldValue)
// on every SET (the hook reads modifier.$set, so it only ever fires for a
// real value, never for unsetDue/unsetStart/unsetEnd/unsetReceived's
// $unset). Registering them here just wires the existing activity into the
// same TriggersDef-driven matcher every other trigger already uses - no new
// detection mechanism.
'a-receivedAt': {
matchingFields: ['boardId', 'userId'],
},
'a-startAt': {
matchingFields: ['boardId', 'userId'],
},
'a-dueAt': {
matchingFields: ['boardId', 'userId'],
},
'a-endAt': {
matchingFields: ['boardId', 'userId'],
},
};