polfan-server-js-client 0.2.74 → 0.2.75

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polfan-server-js-client",
3
- "version": "0.2.74",
3
+ "version": "0.2.75",
4
4
  "description": "JavaScript client library for handling communication with Polfan chat server.",
5
5
  "author": "Jarosław Żak",
6
6
  "license": "MIT",
@@ -20,14 +20,7 @@ import {PromiseRegistry} from "./AsyncUtils";
20
20
  const getOvId = (
21
21
  location: ChatLocation,
22
22
  target?: PermissionOverwritesTarget,
23
- ) => [
24
- location.roomId ? null : location.spaceId, // unify declaration of both space and room level overwrites
25
- location.roomId,
26
- location.topicId,
27
- target?.type,
28
- target?.userId,
29
- target?.roleId,
30
- ].filter(Boolean).join('/');
23
+ ) => [location.spaceId, location.roomId, location.topicId, target?.type, target?.userId, target?.roleId].filter(Boolean).join('/');
31
24
 
32
25
  const getOvIdByObject
33
26
  = (overwrites: PermissionOverwrites | PermissionOverwritesUpdated): string => getOvId(overwrites.location, overwrites.target);
@@ -116,6 +109,13 @@ export class PermissionsManager extends EventTarget {
116
109
  }
117
110
 
118
111
  public async calculatePermissions(location: ChatLocation): Promise<number> {
112
+ const room = location.roomId ? (await this.tracker.rooms.get()).get(location.roomId) : null;
113
+ location = {
114
+ spaceId: location.spaceId ?? room?.spaceId,
115
+ roomId: location.roomId,
116
+ topicId: location.topicId,
117
+ };
118
+
119
119
  this.validateLocation(location);
120
120
 
121
121
  const userId = (await this.tracker.getMe()).id;
@@ -132,7 +132,7 @@ export class PermissionsManager extends EventTarget {
132
132
  promises.push(this.getOverwrites(filterLocation, { type: 'User', userId }).then(v => v.overwrites));
133
133
  }
134
134
 
135
- if (location.roomId && (await this.tracker.rooms.get())?.has(location.roomId)) {
135
+ if (room) {
136
136
  const filterLocation: ChatLocation = {spaceId: location.spaceId, roomId: location.roomId};
137
137
  if (userRoles.length) {
138
138
  promises.push(this.collectRoleOverwrites(filterLocation, userRoles));