Add the includeRequestor option and deprecate includeGM in the notify socket #21

Merged
Oliver merged 2 commits from feature/includeRequestor into main 2026-01-10 04:24:23 +00:00
2 changed files with 19 additions and 4 deletions
Showing only changes of commit f289c94c0a - Show all commits

View file

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

View file

@ -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
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`, {
event: `query.notify`,
payload: {
id: requestID,
userID,
content,
includeGM,
includeGM, // TODO: remove this code with #19
includeRequestor,
},
});
};