@tmlmobilidade/interfaces 20251002.1508.28 → 20251002.1616.54-staging.0
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.
|
@@ -44,7 +44,6 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
|
|
|
44
44
|
phone?: string | null | undefined | undefined;
|
|
45
45
|
email: string;
|
|
46
46
|
permissions: import("@tmlmobilidade/types").Permission<unknown>[];
|
|
47
|
-
active_notifications: string[];
|
|
48
47
|
avatar?: string | null | undefined | undefined;
|
|
49
48
|
bio?: string | null | undefined | undefined;
|
|
50
49
|
email_verified?: import("@tmlmobilidade/types").UnixTimestamp | null | undefined;
|
|
@@ -54,7 +53,6 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
|
|
|
54
53
|
preferences?: Record<string, Record<string, string | number | boolean | string[] | number[]>> | null | undefined;
|
|
55
54
|
role_ids: string[];
|
|
56
55
|
session_ids: string[];
|
|
57
|
-
subscribed_topics: string[];
|
|
58
56
|
theme_id?: string | null | undefined | undefined;
|
|
59
57
|
verification_token_ids: string[];
|
|
60
58
|
_id: string;
|
|
@@ -77,7 +75,6 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
|
|
|
77
75
|
phone?: string | null | undefined | undefined;
|
|
78
76
|
email: string;
|
|
79
77
|
permissions: import("@tmlmobilidade/types").Permission<unknown>[];
|
|
80
|
-
active_notifications: string[];
|
|
81
78
|
avatar?: string | null | undefined | undefined;
|
|
82
79
|
bio?: string | null | undefined | undefined;
|
|
83
80
|
email_verified?: import("@tmlmobilidade/types").UnixTimestamp | null | undefined;
|
|
@@ -87,7 +84,6 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
|
|
|
87
84
|
preferences?: Record<string, Record<string, string | number | boolean | string[] | number[]>> | null | undefined;
|
|
88
85
|
role_ids: string[];
|
|
89
86
|
session_ids: string[];
|
|
90
|
-
subscribed_topics: string[];
|
|
91
87
|
theme_id?: string | null | undefined | undefined;
|
|
92
88
|
verification_token_ids: string[];
|
|
93
89
|
_id: string;
|
|
@@ -20,20 +20,12 @@ class NotificationsClass extends MongoCollectionClass {
|
|
|
20
20
|
return NotificationsClass._instance;
|
|
21
21
|
}
|
|
22
22
|
async sendNotification(notification) {
|
|
23
|
-
const usersWithTopic = await users.findMany({
|
|
23
|
+
const usersWithTopic = await users.findMany({ 'permissions.action': notification.topic });
|
|
24
24
|
if (usersWithTopic.length === 0)
|
|
25
25
|
return;
|
|
26
26
|
for (const user of usersWithTopic.filter(u => u._id !== notification.created_by)) {
|
|
27
27
|
const newNotification = { ...notification, user_id: user._id };
|
|
28
|
-
|
|
29
|
-
const response = await notifications.insertOne(newNotification);
|
|
30
|
-
users.updateById(user._id, {
|
|
31
|
-
active_notifications: [...(user.active_notifications || []), response._id],
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
catch (err) {
|
|
35
|
-
console.error('Failed to update user notifications:', err);
|
|
36
|
-
}
|
|
28
|
+
await notifications.insertOne(newNotification);
|
|
37
29
|
}
|
|
38
30
|
}
|
|
39
31
|
getCollectionIndexes() {
|
|
@@ -29,7 +29,7 @@ class AuthProvider {
|
|
|
29
29
|
// Get the user and their roles
|
|
30
30
|
const userData = await this.getUser(sessionToken);
|
|
31
31
|
const rolesData = await roles.findMany({ _id: { $in: userData.role_ids } });
|
|
32
|
-
const allPermissions = [...rolesData.flatMap(role => role.permissions), ...userData.permissions
|
|
32
|
+
const allPermissions = [...rolesData.flatMap(role => role.permissions), ...userData.permissions];
|
|
33
33
|
const permissionsMap = new Map();
|
|
34
34
|
for (const permission of allPermissions) {
|
|
35
35
|
const key = `${permission.scope}:${permission.action}`;
|
package/package.json
CHANGED