Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix admin delete group API call #34909

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
25 changes: 18 additions & 7 deletions apps/meteor/app/api/server/v1/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ async function findPrivateGroupByIdOrName({
userId,
}: {
params:
| {
roomId?: string;
}
| {
roomName?: string;
};
| {
roomId?: string;
}
| {
roomName?: string;
};
userId: string;
checkedArchived?: boolean;
}): Promise<{
Expand All @@ -88,10 +88,21 @@ async function findPrivateGroupByIdOrName({

const user = await Users.findOneById(userId, { projections: { username: 1 } });

if (!room || !user || !(await canAccessRoomAsync(room, user))) {
if (!user) {
throw new Meteor.Error('error-user-not-found', 'User not found');
}

if (user.roles?.includes('admin') || (room && await canAccessRoomAsync(room, user))) {
// Continue if the user is an admin or has access to the room
} else {
throw new Meteor.Error('error-room-not-found', 'The required "roomId" or "roomName" param provided does not match any group');
}


// if (!room || !user || !(await canAccessRoomAsync(room, user))) {
// throw new Meteor.Error('error-room-not-found', 'The required "roomId" or "roomName" param provided does not match any group');
// }

// discussions have their names saved on `fname` property
const roomName = room.prid ? room.fname : room.name;

Expand Down
Loading