From f2f742e65a2a167156ab3a88680bf969e2e049dc Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Sun, 4 May 2025 21:35:54 -0600 Subject: [PATCH] Put all the relevant privacy helpers into their own module --- module/api.mjs | 2 +- .../{filterPrivateRows.mjs => privacy.mjs} | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) rename module/utils/{filterPrivateRows.mjs => privacy.mjs} (66%) diff --git a/module/api.mjs b/module/api.mjs index 9fe62f0..a6587a0 100644 --- a/module/api.mjs +++ b/module/api.mjs @@ -4,7 +4,7 @@ import { TableCreator } from "./Apps/TableCreator.mjs"; import { TestApp } from "./Apps/TestApp.mjs"; // Utils -import { filterPrivateRows } from "./utils/filterPrivateRows.mjs"; +import { filterPrivateRows } from "./utils/privacy.mjs"; import { validateValue } from "./utils/validateValue.mjs"; const { deepFreeze } = foundry.utils; diff --git a/module/utils/filterPrivateRows.mjs b/module/utils/privacy.mjs similarity index 66% rename from module/utils/filterPrivateRows.mjs rename to module/utils/privacy.mjs index 46873a6..12aefd1 100644 --- a/module/utils/filterPrivateRows.mjs +++ b/module/utils/privacy.mjs @@ -1,3 +1,22 @@ +export const PrivacyMode = Object.freeze({ + GM: `gm`, + PRIVATE: `private`, + SELF: `self`, + PUBLIC: `public`, +}); + +export function determinePrivacyFromRollMode(rollMode) { + switch (rollMode) { + case CONST.DICE_ROLL_MODES.BLIND: + return PrivacyMode.GM; + case CONST.DICE_ROLL_MODES.PRIVATE: + return PrivacyMode.PRIVATE; + case CONST.DICE_ROLL_MODES.SELF: + return PrivacyMode.SELF; + } + return PrivacyMode.PUBLIC; +}; + /** * Filters an array of database rows based on if the current user would * be able to see them based on the privacy level.