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:
commit
353f1b2101
2 changed files with 20 additions and 5 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ async function sendBasicNotification(requestID, userID, answers) {
|
|||
{ answers },
|
||||
);
|
||||
|
||||
await notify(requestID, userID, content, { includeGM: false });
|
||||
await notify(requestID, userID, content, { includeRequestor: false });
|
||||
};
|
||||
|
||||
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
|
||||
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,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue