-
Notifications
You must be signed in to change notification settings - Fork 13.5k
feat: Allow admins to decide if email transcript should be sent always #32820
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
22 commits
Select commit
Hold shift + click to select a range
6ef0532
always send transcript
KevLehman 8b41a86
update ui and dont send prompttranscript when not needed
KevLehman 7cdef49
lint
KevLehman e11be8c
lint
KevLehman 07f09e1
test
KevLehman 525052f
Create shaggy-hats-raise.md
KevLehman 628c93f
Update shaggy-hats-raise.md
KevLehman 34882a1
translations
KevLehman dbad845
Merge branch 'develop' into feat/always-send-transcript
KevLehman c34dc7c
Update parseTranscriptRequest.spec.ts
KevLehman 9a196eb
Update .changeset/shaggy-hats-raise.md
KevLehman 4748625
Merge branch 'develop' into feat/always-send-transcript
KevLehman 4cff36c
Update packages/i18n/src/locales/en.i18n.json
KevLehman 70a52a5
cr & qa suggestions
KevLehman 70f8928
jesus im dum
KevLehman 77b86da
translations
KevLehman afc7c57
more expect
KevLehman 0b0ebb6
effect
KevLehman e3ed193
martin
KevLehman a1089ee
Merge branch 'develop' into feat/always-send-transcript
KevLehman 3bb5c58
Merge branch 'develop' into feat/always-send-transcript
KevLehman 473bc6a
Merge branch 'develop' into feat/always-send-transcript
ggazzo 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,5 @@ | ||
| --- | ||
| "@rocket.chat/meteor": minor | ||
| --- | ||
|
|
||
| Added a new setting `Livechat_transcript_send_always` that allows admins to decide if email transcript should be sent all the times when a conversation is closed. This setting bypasses agent's preferences. For this setting to work, `Livechat_enable_transcript` should be off, meaning that visitors will no longer receive the option to decide if they want a transcript or not. | ||
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 |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import type { IOmnichannelRoom, IUser, ILivechatVisitor } from '@rocket.chat/core-typings'; | ||
|
|
||
| export type GenericCloseRoomParams = { | ||
| room: IOmnichannelRoom; | ||
| comment?: string; | ||
| options?: { | ||
| clientAction?: boolean; | ||
| tags?: string[]; | ||
| emailTranscript?: | ||
| | { | ||
| sendToVisitor: false; | ||
| } | ||
| | { | ||
| sendToVisitor: true; | ||
| requestData: NonNullable<IOmnichannelRoom['transcriptRequest']>; | ||
| }; | ||
| pdfTranscript?: { | ||
| requestedBy: string; | ||
| }; | ||
| }; | ||
| }; | ||
|
|
||
| export type CloseRoomParamsByUser = { | ||
| user: IUser | null; | ||
| } & GenericCloseRoomParams; | ||
|
|
||
| export type CloseRoomParamsByVisitor = { | ||
| visitor: ILivechatVisitor; | ||
| } & GenericCloseRoomParams; | ||
|
|
||
| export type CloseRoomParams = CloseRoomParamsByUser | CloseRoomParamsByVisitor; |
61 changes: 61 additions & 0 deletions
61
apps/meteor/app/livechat/server/lib/parseTranscriptRequest.ts
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,61 @@ | ||
| import type { ILivechatVisitor, IOmnichannelRoom, IUser } from '@rocket.chat/core-typings'; | ||
| import { LivechatVisitors, Users } from '@rocket.chat/models'; | ||
|
|
||
| import { settings } from '../../../settings/server'; | ||
| import type { CloseRoomParams } from './localTypes'; | ||
|
|
||
| export const parseTranscriptRequest = async ( | ||
| room: IOmnichannelRoom, | ||
| options: CloseRoomParams['options'], | ||
| visitor?: ILivechatVisitor, | ||
| user?: IUser, | ||
| ): Promise<CloseRoomParams['options']> => { | ||
| const visitorDecideTranscript = settings.get<boolean>('Livechat_enable_transcript'); | ||
| // visitor decides, no changes | ||
| if (visitorDecideTranscript) { | ||
| return options; | ||
| } | ||
|
|
||
| // send always is disabled, no changes | ||
| const sendAlways = settings.get<boolean>('Livechat_transcript_send_always'); | ||
| if (!sendAlways) { | ||
| return options; | ||
| } | ||
|
|
||
| const visitorData = | ||
| visitor || | ||
| (await LivechatVisitors.findOneById<Pick<ILivechatVisitor, 'visitorEmails'>>(room.v._id, { projection: { visitorEmails: 1 } })); | ||
| // no visitor, no changes | ||
| if (!visitorData) { | ||
| return options; | ||
| } | ||
| const visitorEmail = visitorData?.visitorEmails?.[0]?.address; | ||
| // visitor doesnt have email, no changes | ||
| if (!visitorEmail) { | ||
| return options; | ||
| } | ||
|
|
||
| const defOptions = { projection: { _id: 1, username: 1, name: 1 } }; | ||
| const requestedBy = | ||
| user || | ||
| (room.servedBy && (await Users.findOneById(room.servedBy._id, defOptions))) || | ||
| (await Users.findOneById('rocket.cat', defOptions)); | ||
|
|
||
| // no user available for backing request, no changes | ||
| if (!requestedBy) { | ||
| return options; | ||
| } | ||
|
|
||
| return { | ||
| ...options, | ||
| emailTranscript: { | ||
| sendToVisitor: true, | ||
| requestData: { | ||
| email: visitorEmail, | ||
| requestedAt: new Date(), | ||
| subject: '', | ||
| requestedBy, | ||
| }, | ||
| }, | ||
| }; | ||
| }; |
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
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.