Files
wekan/server/publications/backgrounds.js
T
Lauri Ojansivu f122a8287c Add semi-open boards, visible to every signed-in user.
A board's visibility can now be "Signed-in users" (permission 'instance'):
every signed-in user of this WeKan reads it, nobody signed out does, and
only its members edit it, as on a public board. One pure rule,
models/lib/boardPermission.js, feeds isVisibleBy and the shared selector
builder, so the board and card publications, All Boards, search, exports,
attachments, backgrounds, watching, filter presets and rule destinations
follow it. Anonymous paths - link previews, public avatars, the no-token
export branch and archived lists - stay public-only, and a source suite
lists every remaining public-only check so a new one is reviewed. The
Public page and GET /api/boards list instance boards for a signed-in caller
only; "private boards only" refuses them like public ones; a WeKan export
keeps the setting on import. New strings are English, pending Transifex.

Fixes #3249,

Thanks to relikd and xet7 !
2026-09-29 16:28:44 +03:00

29 lines
1.1 KiB
JavaScript

import Attachments from '/models/attachments';
import { ReactiveCache } from '/imports/reactiveCache';
import { liveAttachments } from '/models/lib/attachmentSoftDelete';
const { readableWithoutMembership } = require('/models/lib/boardPermission');
// Publish a board's background images so the board-settings backgrounds list
// can show them. Board backgrounds are stored as board-level Attachments
// (meta.boardId set, no meta.cardId, meta.source === 'board-background').
Meteor.publish('boardBackgrounds', async function (boardId) {
check(boardId, String);
if (!this.userId) {
return this.ready();
}
const board = await ReactiveCache.getBoard(boardId);
if (!board) {
return this.ready();
}
// Signed in (checked above), so an 'instance' board (#3249) is readable too.
const readable = readableWithoutMembership(board.permission, true);
const isMember = board.hasMember && board.hasMember(this.userId);
if (!readable && !isMember) {
return this.ready();
}
return Attachments.collection.find(liveAttachments({
'meta.boardId': boardId,
'meta.source': 'board-background',
}));
});