@openinc/parse-server-opendash 4.4.5 → 4.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/Chat_Message.js +15 -1
- package/package.json +1 -1
|
@@ -13,7 +13,21 @@ const index_js_2 = require("../types/index.js");
|
|
|
13
13
|
async function init() {
|
|
14
14
|
(0, index_js_1.beforeSaveHook)(index_js_2.Chat_Message, async (request) => {
|
|
15
15
|
await (0, index_js_1.defaultHandler)(request);
|
|
16
|
-
|
|
16
|
+
// `allowTenantUserWrite` because reacting is an update on *someone else's*
|
|
17
|
+
// message (see `useToggleReaction` in the chat plugin) — without it only
|
|
18
|
+
// tenant admins could react. Who may edit or delete what is enforced in the
|
|
19
|
+
// UI (`isOwn`); the ACL only has to let the write through.
|
|
20
|
+
await (0, index_js_1.defaultAclHandler)(request, { allowTenantUserWrite: true });
|
|
21
|
+
// Chat_Message carries `author`, not `user`, so `defaultAclHandler` — which
|
|
22
|
+
// looks for a `user` field — never grants the owner write access. Grant it
|
|
23
|
+
// explicitly, so an author can always edit and soft-delete their own
|
|
24
|
+
// message, independent of their tenant roles. This mirrors the ACL the v1
|
|
25
|
+
// migration already writes for chat messages (see
|
|
26
|
+
// `scripts/migration/passes/10-chat.ts`).
|
|
27
|
+
const author = request.object.get("author");
|
|
28
|
+
if (author?.id) {
|
|
29
|
+
request.object.getACL()?.setWriteAccess(author.id, true);
|
|
30
|
+
}
|
|
17
31
|
});
|
|
18
32
|
(0, index_js_1.afterSaveHook)(index_js_2.Chat_Message, async ({ object, original }) => {
|
|
19
33
|
try {
|