Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/proud-drinks-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fixes an issue where some apps that don't need permission would have grantedPermissions as null making it impossible to activate the app
15 changes: 6 additions & 9 deletions apps/meteor/ee/server/apps/storage/AppRealStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,15 @@ export class AppRealStorage extends AppMetadataStorage {
return items;
}

public async update(item: IAppStorageItem): Promise<IAppStorageItem> {
public async update({ permissionsGranted, ...item }: IAppStorageItem): Promise<IAppStorageItem> {
const updateQuery: UpdateFilter<IAppStorageItem> = {
$set: item,
$set: { ...item, ...(permissionsGranted && { permissionsGranted }) },
// Note: This is really important, since we currently store the permissionsGranted as null if none are present
// in the App's manifest. So, if there was a permissionGranted and it was removed, we must see the app as having
// no permissionsGranted at all (which means default permissions). So we must actively unset the field.
...(!permissionsGranted && { $unset: { permissionsGranted: 1 } }),
};

// Note: This is really important, since we currently store the permissionsGranted as null if none are present
// in the App's manifest. So, if there was a permissionGranted and it was removed, we must see the app as having
// no permissionsGranted at all (which means default permissions). So we must actively unset the field.
if (!item.permissionsGranted) {
updateQuery.$unset = { permissionsGranted: 1 };
}

return this.db.findOneAndUpdate({ id: item.id, _id: item._id }, updateQuery, { returnDocument: 'after' });
}

Expand Down
Loading