-
Notifications
You must be signed in to change notification settings - Fork 1
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
[FIX] Unset Visitor Phone on Empty String for Test Widget #1142
Conversation
@AlexanderKanakis I was testing it locally. Currently, it is clearing phoneNumber from the DB every time. You can check the collection |
ISSUE: This might clear the phoneNumber from a whatsApp user as well. This will be a problem. This feature needs somehow to be specific to only testWidget users, from a browser, using our test widget. This implementation is currently running for every user, and it needs to only run for the specific widget user in play. |
New Design!!! Back to the original design...... create an unsetPhone function and call it from the widget in the case that no phoneNumber has been provided. |
app/livechat/server/lib/Livechat.js
Outdated
@@ -307,11 +307,15 @@ export const Livechat = { | |||
const updateUser = { | |||
$set: { | |||
token, | |||
...(phone?.number ? { phone: [{ phoneNumber: phone.number }] } : {}), | |||
...(phone?.number && phone.number !== 'delete' ? { phone: [{ phoneNumber: phone.number }] } : {}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're still looking for 'delete' here? didn't you change this to 'null'? so should this be phone.number !== undefined? Or, do you even need this condition here?
if (phone === undefined) { | ||
updateUser.$unset = { phone: [] }; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlexanderKanakis @ear-dev I'm still seeing the same behavior. In the DB, the phone number is not stored.
When I uncommented this code. It is being stored in the DB.
And it needs to be stored in DB. Because... For Twilio integration, we use this phone number to send messages.
@AlexanderKanakis I think the reason for this issue is because registerGuest
function is used for registering users as well as updating users. So it can be called multiple times. And when registering/updating for some other property, phoneNumber becomes undefined and that unsets it in db
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps then using 'delete', the way @AlexanderKanakis originally designed it is the best solution? It is surely only in our test widget that 'delete' would be set for phone number. @Shailesh351 is that our best design do you think?
Proposed changes (including videos or screenshots)
For Issue: #1139
Updates the visitor entry by unsetting the phone field id the Test Widget phone field is empty.
Issue(s)
Steps to test or reproduce
Further comments