Skip to content

Commit

Permalink
Fix setGuestPhone to support empty/null/undefined (#1178)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shailesh351 authored May 16, 2022
1 parent 7035a79 commit 2871f70
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/livechat/server/api/v1/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ API.v1.addRoute('livechat/visitor', {
const { token, customFields } = this.bodyParams.visitor;
const guest: ILivechatVisitorDTO = { ...this.bodyParams.visitor };

if (this.bodyParams.visitor.phone) {
if (this.bodyParams.visitor.phone || this.bodyParams.visitor.phone === '') {
guest.phone = { number: this.bodyParams.visitor.phone as string };
}

Expand Down
4 changes: 4 additions & 0 deletions app/livechat/server/lib/Livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,10 @@ export const Livechat = {
},
};

if (phone && phone.number === '') {
updateUser.$unset = { phone: [] };
}

if (email) {
email = email.trim();
validateEmail(email);
Expand Down

0 comments on commit 2871f70

Please sign in to comment.