@fabriktor/fx 0.0.147 → 0.0.148
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/src/chat/forms.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { normalizeIDs, resolvedID } from "../core/id.js";
|
|
2
|
-
import { isFabriktorUser, userSupportsMode } from "../users/users.js";
|
|
2
|
+
import { isFabriktorUser, isOtherUserID, userSupportsMode, } from "../users/users.js";
|
|
3
3
|
// Recipients are all other members of the conversation, resolved before use.
|
|
4
4
|
// Sender modes apply now; recipient modes describe what their identity supports.
|
|
5
5
|
// Do not depend on the recipient's current mode, which Public() omits.
|
|
@@ -10,7 +10,7 @@ export function canSendChatForm(policy, actor, recipients) {
|
|
|
10
10
|
(policy.allow_group || recipients.length === 1) &&
|
|
11
11
|
normalizeIDs(recipients.map((recipient) => recipient.id)).length ===
|
|
12
12
|
recipients.length &&
|
|
13
|
-
recipients.every((recipient) => recipient.id
|
|
13
|
+
recipients.every((recipient) => isOtherUserID(recipient.id, actor.owner_id) &&
|
|
14
14
|
isFabriktorUser(recipient) &&
|
|
15
15
|
policy.recipient_modes.some((mode) => userSupportsMode(recipient, mode))));
|
|
16
16
|
}
|
|
@@ -17,6 +17,7 @@ export type UpdateExternalUserOptions = {
|
|
|
17
17
|
};
|
|
18
18
|
export declare function userSupportsMode(user: Pick<User, "account_identity"> | null | undefined, mode: User["active_mode"]): boolean;
|
|
19
19
|
export declare function isFabriktorUser(user: Pick<User, "account_identity"> | null | undefined): boolean;
|
|
20
|
+
export declare function isOtherUserID(user_id: string | null | undefined, owner_id: string | null | undefined): boolean;
|
|
20
21
|
export declare function canManageExternalUser(user: User | null | undefined, owner_id: string): boolean;
|
|
21
22
|
export type SearchExternalUsersOptions = SearchUsersOptions;
|
|
22
23
|
export type SearchExternalUsersPage = SearchUsersPage;
|
package/dist/src/users/users.js
CHANGED
|
@@ -44,6 +44,13 @@ export function userSupportsMode(user, mode) {
|
|
|
44
44
|
export function isFabriktorUser(user) {
|
|
45
45
|
return userSupportsMode(user, UserTypeClient);
|
|
46
46
|
}
|
|
47
|
+
// Client capability and being a different party are separate requirements.
|
|
48
|
+
// Apply this to counterparties, not to ownership or employee scope filters.
|
|
49
|
+
export function isOtherUserID(user_id, owner_id) {
|
|
50
|
+
const userID = resolvedID(user_id ?? undefined);
|
|
51
|
+
const ownerID = resolvedID(owner_id ?? undefined);
|
|
52
|
+
return !!userID && !!ownerID && userID !== ownerID;
|
|
53
|
+
}
|
|
47
54
|
export function canManageExternalUser(user, owner_id) {
|
|
48
55
|
return (!!resolvedID(owner_id) &&
|
|
49
56
|
user?.account_identity === UserTypeExternal &&
|