Files
wekan/server/lib/assistGate.js
T
Lauri Ojansivu f8267d704e Due date from the card title, and similar cards and possible duplicates.
Two of the features other kanban apps call AI, done with plain code
(docs/Features/General/Assistants/Assistants.md):

- A due date typed at the end of a new card's title ("... tomorrow 14:00",
  "huomenna klo 14", "friday 9:30", "in 3 days", "23.10.") becomes the card's
  due date, read with the browser's own Intl tables so every language works.
  A hint under the field shows the date, and its x keeps the words. The
  opened card's title reads it too, but only when the title changed.
- Similar cards: letter triples and the Dice coefficient (letter pairs for
  scripts without spaces). The add-card form lists up to three close cards,
  marking a possible duplicate, and the opened card has a Similar cards
  section. The server method applies the board's read rules and the
  assigned-only role.

Both are rows of Board Settings / Card and of Admin Panel / Settings /
Visibility / Features / Card fields, so a board admin or a site admin can
hide them. Translated in every language.

Thanks to xet7 !
2026-10-17 14:39:43 +03:00

34 lines
1.5 KiB
JavaScript

import { ReactiveCache } from '/imports/reactiveCache';
import { canReadBoard } from '/models/lib/boardVisibility';
// The server half of hiding the helpers that need no AI
// (docs/Features/General/Assistants/Assistants.md). A hidden helper answers
// nothing, whoever calls it: the interface not drawing it is the visible half,
// this is the half a crafted call meets.
const { isCardFieldEnabled } = require('/models/lib/cardFieldVisibility');
const { isFeatureAvailable } = require('/models/lib/instanceFeatures');
// The board, when this user may read it and a card helper is on for that side:
// the board's Board Settings / Card flag (on unless set false) and the
// Admin Panel / Settings / Visibility / Features / Card fields tick.
export async function boardForCardHelper(userId, boardId, cardField, boardFlag) {
if (!userId || typeof boardId !== 'string') return null;
const board = await ReactiveCache.getBoard(boardId);
if (!board || !canReadBoard(userId, board)) return null;
if (board[boardFlag] === false) return null;
const setting = await ReactiveCache.getCurrentSetting();
if (!isCardFieldEnabled(setting, cardField)) return null;
return board;
}
// Whether an Admin Panel / Settings / Visibility / Features entry is on for
// this user (or they preview it).
export async function featureOnFor(userId, key) {
if (!userId) return false;
const [setting, user] = await Promise.all([
ReactiveCache.getCurrentSetting(),
ReactiveCache.getUser(userId),
]);
return isFeatureAvailable(setting, user, key);
}