-
Notifications
You must be signed in to change notification settings - Fork 13.1k
chore: Adds deprecation warning for livechat:saveTag and new endpoint to replace it
#37281
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
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
437fad8
chore: adds deprecation warning for livechat:saveTag
lucas-a-pelegrino 3e34045
chore: adds a new endpoint to handle the saving of tags
lucas-a-pelegrino bf1c7c1
chore: updates test helpers to use the new endpoint instead of livech…
lucas-a-pelegrino e9ad5e1
chore: updates the client to use the new endpoint instead of livechat…
lucas-a-pelegrino d800086
docs: adds changeset
lucas-a-pelegrino 2a41bf9
fix: linting errors
lucas-a-pelegrino e4c953a
fix: prettier formatting
lucas-a-pelegrino 181c258
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into chor…
lucas-a-pelegrino e552717
fix: CreateTagParams types; request body params
lucas-a-pelegrino 2ac8925
fix: livechat method name
lucas-a-pelegrino 2882d40
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into chor…
lucas-a-pelegrino b784926
fix: Meteor.Error with wrong method name
lucas-a-pelegrino 4fd53d6
chore: adds minor improvement to the livechat/tags.save endpoint layer
lucas-a-pelegrino 34d69ad
Merge remote-tracking branch 'origin/chore/v7/CORE-1411' into chore/v…
lucas-a-pelegrino f16d490
chore: adds improvements suggested from code reviews
lucas-a-pelegrino 2534616
chore: applies code review suggestions
lucas-a-pelegrino 0f8a0a2
fix: merge conflicts
lucas-a-pelegrino e555f46
chore: adds minor improvements to tags testing functions
lucas-a-pelegrino 97c3113
chore: adds minor improvements to tag saving logic
lucas-a-pelegrino a22519f
fix: linting error
lucas-a-pelegrino d20dea5
chore: adds minor improvement to createTag helper
lucas-a-pelegrino 714ac3b
fix: merge conflicts
lucas-a-pelegrino 65a4fae
fix: merge conflicts in omnichannel.ts
lucas-a-pelegrino ec0848b
Merge branch 'develop' into chore/v7/CORE-1411
tassoevan e2da75e
Merge branch 'develop' into chore/v7/CORE-1411
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@rocket.chat/meteor": patch | ||
| "@rocket.chat/rest-typings": patch | ||
| --- | ||
|
|
||
| Adds deprecation warning for `livechat:saveTag` and new endpoint to replace it; `livechat/tags.save` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,49 +1,40 @@ | ||
| import { faker } from '@faker-js/faker'; | ||
| import type { ILivechatTag } from '@rocket.chat/core-typings'; | ||
|
|
||
| import { credentials, methodCall, request } from '../api-data'; | ||
| import type { DummyResponse } from './utils'; | ||
|
|
||
| export const saveTags = (departments: string[] = []): Promise<ILivechatTag> => { | ||
| return new Promise((resolve, reject) => { | ||
| void request | ||
| .post(methodCall(`livechat:saveTag`)) | ||
| .set(credentials) | ||
| .send({ | ||
| message: JSON.stringify({ | ||
| method: 'livechat:saveTag', | ||
| params: [undefined, { name: faker.string.uuid(), description: faker.lorem.sentence() }, departments], | ||
| id: '101', | ||
| msg: 'method', | ||
| }), | ||
| }) | ||
| .end((err: Error, res: DummyResponse<string, 'wrapped'>) => { | ||
| if (err) { | ||
| return reject(err); | ||
| } | ||
| resolve(JSON.parse(res.body.message).result); | ||
| }); | ||
| }); | ||
| import type { ILivechatTag, FindTagsResult } from '@rocket.chat/core-typings'; | ||
|
|
||
| import { credentials, request, api } from '../api-data'; | ||
|
|
||
| export const listTags = async (): Promise<FindTagsResult> => { | ||
| const { body } = await request.get(api('livechat/tags')).set(credentials).query({ viewAll: 'true' }); | ||
|
|
||
| return body; | ||
| }; | ||
|
|
||
| export const saveTags = async (departments: string[] = []): Promise<ILivechatTag> => { | ||
| const { body } = await request | ||
| .post(api('livechat/tags.save')) | ||
| .set(credentials) | ||
| .send({ | ||
| tagData: { | ||
| name: faker.string.uuid(), | ||
| description: faker.lorem.sentence(), | ||
| }, | ||
| ...(departments.length > 0 && { tagDepartments: departments }), | ||
| }); | ||
|
|
||
| return body; | ||
| }; | ||
|
|
||
| export const removeTag = (id: string): Promise<boolean> => { | ||
| return new Promise((resolve, reject) => { | ||
| void request | ||
| .post(methodCall(`livechat:removeTag`)) | ||
| .set(credentials) | ||
| .send({ | ||
| message: JSON.stringify({ | ||
| method: 'livechat:removeTag', | ||
| params: [id], | ||
| id: '101', | ||
| msg: 'method', | ||
| }), | ||
| }) | ||
| .end((err: Error, res: DummyResponse<string, 'wrapped'>) => { | ||
| if (err) { | ||
| return reject(err); | ||
| } | ||
| resolve(JSON.parse(res.body.message).result); | ||
| }); | ||
| }); | ||
| export const removeTag = async (id: string): Promise<boolean> => { | ||
| const res = await request.post(api('livechat/tags.delete')).set(credentials).send({ id }); | ||
|
|
||
| return res.status === 200; | ||
| }; | ||
|
|
||
| export const removeAllTags = async (): Promise<boolean> => { | ||
| const tagsList = await listTags(); | ||
| await Promise.all(tagsList.tags.map((tag) => removeTag(tag._id))); | ||
|
|
||
| const response = await request.get(api('livechat/tags')).set(credentials).expect('Content-Type', 'application/json').expect(200); | ||
|
|
||
| return response.body.tags.length === 0; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,35 @@ | ||
| import type { ILivechatTag } from '@rocket.chat/core-typings'; | ||
|
|
||
| import { parseMeteorResponse } from '../parseMeteorResponse'; | ||
| import type { BaseTest } from '../test'; | ||
|
|
||
| type CreateTagParams = { | ||
| id?: string | null; | ||
| name?: string; | ||
| description?: string; | ||
| departments?: { departmentId: string }[]; | ||
| departments?: string[]; | ||
| }; | ||
|
|
||
| const removeTag = async (api: BaseTest['api'], id: string) => api.post('/livechat/tags.delete', { id }); | ||
|
|
||
| export const createTag = async (api: BaseTest['api'], { id = null, name, description = '', departments = [] }: CreateTagParams = {}) => { | ||
| const response = await api.post('/method.call/livechat:saveTag', { | ||
| message: JSON.stringify({ | ||
| msg: 'method', | ||
| id: '33', | ||
| method: 'livechat:saveTag', | ||
| params: [id, { name, description }, departments], | ||
| }), | ||
| const response = await api.post('/livechat/tags.save', { | ||
| _id: id, | ||
| tagData: { | ||
| name, | ||
| description, | ||
| }, | ||
| ...(departments.length > 0 && { tagDepartments: departments }), | ||
| }); | ||
|
|
||
| const tag = await parseMeteorResponse<ILivechatTag>(response); | ||
| if (response.status() !== 200) { | ||
| throw new Error(`Failed to create tag [http status: ${response.status()}]`); | ||
| } | ||
|
|
||
| const data: ILivechatTag = await response.json(); | ||
|
|
||
| return { | ||
| response, | ||
| data: tag, | ||
| delete: async () => removeTag(api, tag?._id), | ||
| data, | ||
| delete: async () => removeTag(api, data._id), | ||
| }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.