Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RocketChat
Rocket.Chat
Commits
2d372dca
Unverified
Commit
2d372dca
authored
1 year ago
by
Heitor Tanoue
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: Deleted DM rooms can't be closed (#29984)
parent
e0dfbda7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/meteor/app/api/server/v1/im.ts
+21
-6
21 additions, 6 deletions
apps/meteor/app/api/server/v1/im.ts
with
21 additions
and
6 deletions
apps/meteor/app/api/server/v1/im.ts
+
21
−
6
View file @
2d372dca
...
@@ -123,18 +123,33 @@ API.v1.addRoute(
...
@@ -123,18 +123,33 @@ API.v1.addRoute(
if
(
!
roomId
)
{
if
(
!
roomId
)
{
throw
new
Meteor
.
Error
(
'
error-room-param-not-provided
'
,
'
Body param "roomId" is required
'
);
throw
new
Meteor
.
Error
(
'
error-room-param-not-provided
'
,
'
Body param "roomId" is required
'
);
}
}
const
canAccess
=
await
canAccessRoomIdAsync
(
roomId
,
this
.
userId
);
if
(
!
canAccess
)
{
let
subscription
;
return
API
.
v1
.
unauthorized
();
const
roomExists
=
!!
(
await
Rooms
.
findOneById
(
roomId
));
if
(
!
roomExists
)
{
// even if the room doesn't exist, we should allow the user to close the subscription anyways
subscription
=
await
Subscriptions
.
findOneByRoomIdAndUserId
(
roomId
,
this
.
userId
);
}
else
{
const
canAccess
=
await
canAccessRoomIdAsync
(
roomId
,
this
.
userId
);
if
(
!
canAccess
)
{
return
API
.
v1
.
unauthorized
();
}
const
{
subscription
:
subs
}
=
await
findDirectMessageRoom
({
roomId
},
this
.
userId
);
subscription
=
subs
;
}
}
const
{
room
,
subscription
}
=
await
findDirectMessageRoom
({
roomId
},
this
.
userId
);
if
(
!
subscription
)
{
return
API
.
v1
.
failure
(
`The user is not subscribed to the room`
);
}
if
(
!
subscription
?
.
open
)
{
if
(
!
subscription
.
open
)
{
return
API
.
v1
.
failure
(
`The direct message room, is already closed to the sender`
);
return
API
.
v1
.
failure
(
`The direct message room, is already closed to the sender`
);
}
}
await
hideRoomMethod
(
this
.
userId
,
room
.
_i
d
);
await
hideRoomMethod
(
this
.
userId
,
room
I
d
);
return
API
.
v1
.
success
();
return
API
.
v1
.
success
();
},
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment