Skip to content

Commit

Permalink
fix: tag endpoint empty result (#35028)
Browse files Browse the repository at this point in the history
Co-authored-by: Kevin Aleman <[email protected]>
  • Loading branch information
ggazzo and KevLehman authored Jan 24, 2025
1 parent 274f322 commit bb5b08d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/three-insects-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixes a missconception about `/v1/livechat/tags/:tagId` returning 404 if tag is not found
16 changes: 10 additions & 6 deletions apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ API.v1.addRoute(
async get() {
const { tagId } = this.urlParams;

return API.v1.success(
await findTagById({
userId: this.userId,
tagId,
}),
);
const tag = await findTagById({
userId: this.userId,
tagId,
});

if (!tag) {
return API.v1.notFound('Tag not found');
}

return API.v1.success(tag);
},
},
);
3 changes: 1 addition & 2 deletions apps/meteor/tests/end-to-end/api/livechat/13-tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,7 @@ import { IS_EE } from '../../../e2e/config/constants';
it('should return null when the tag does not exist', async () => {
await updatePermission('manage-livechat-tags', ['admin']);
await updatePermission('view-l-room', ['livechat-agent']);
const response = await request.get(api('livechat/tags/123')).set(credentials).expect('Content-Type', 'application/json').expect(200);
expect(response.body.body).to.be.null;
await request.get(api('livechat/tags/123')).set(credentials).expect('Content-Type', 'application/json').expect(404);
});
it('should return a tag', async () => {
const tag = await saveTags();
Expand Down

0 comments on commit bb5b08d

Please sign in to comment.