Merge pull request 'Add the includeRequestor option and deprecate includeGM in the notify socket' (#21) from feature/includeRequestor into main

Reviewed-on: #21
This commit is contained in:
Oliver 2026-01-10 04:24:22 +00:00
commit 353f1b2101
2 changed files with 20 additions and 5 deletions

View file

@ -1,8 +1,8 @@
import { localizer } from "../../utils/localizer.mjs"; import { localizer } from "../../utils/localizer.mjs";
import { respondedToQueries } from "../../utils/QueryManager.mjs"; import { respondedToQueries } from "../../utils/QueryManager.mjs";
export function queryNotify(payload) { export function queryNotify(payload, sender) {
const { id, userID, content, includeGM } = payload; const { id, userID, content, includeGM, includeRequestor } = payload;
if (userID !== game.user.id) { return }; if (userID !== game.user.id) { return };
@ -10,10 +10,16 @@ export function queryNotify(payload) {
if (!respondedToQueries.has(id)) { return }; if (!respondedToQueries.has(id)) { return };
let whisper = [game.user.id]; let whisper = [game.user.id];
// TODO: remove this code with #19
if (includeGM) { if (includeGM) {
whisper = game.users.filter(u => u.isGM).map(u => u.id); whisper = game.users.filter(u => u.isGM).map(u => u.id);
}; };
if (includeRequestor) {
whisper = [sender.id];
};
ChatMessage.implementation.create({ ChatMessage.implementation.create({
flavor: localizer(`taf.misc.data-query-notif-header`), flavor: localizer(`taf.misc.data-query-notif-header`),
content, content,

View file

@ -43,7 +43,7 @@ async function sendBasicNotification(requestID, userID, answers) {
{ answers }, { answers },
); );
await notify(requestID, userID, content, { includeGM: false }); await notify(requestID, userID, content, { includeRequestor: false });
}; };
export function has(requestID) { export function has(requestID) {
@ -229,17 +229,26 @@ async function maybeResolve(requestID) {
}; };
}; };
export async function notify(requestID, userID, content, { includeGM = false } = {}) { export async function notify(requestID, userID, content, { includeGM = false, includeRequestor } = {}) {
// Prevent sending notifications for not-your queries // Prevent sending notifications for not-your queries
if (!queries.has(requestID)) { return }; if (!queries.has(requestID)) { return };
// TODO: remove this code with #19
if (includeGM) {
foundry.utils.logCompatibilityWarning(
`The "includeGM" option has been deprecated in favour of "includeRequestor"`,
{ since: `v2.4.0`, until: `v3.0.0` },
);
};
game.socket.emit(`system.taf`, { game.socket.emit(`system.taf`, {
event: `query.notify`, event: `query.notify`,
payload: { payload: {
id: requestID, id: requestID,
userID, userID,
content, content,
includeGM, includeGM, // TODO: remove this code with #19
includeRequestor,
}, },
}); });
}; };