-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
[NEW] Additional Livechat iFrame API's #10918
Conversation
Hi guys, any ETA for this? |
@Leen15 it will be released on 0.66 |
@renatobecker can you please add the new events to our docs as well? https://github.com/RocketChat/docs/tree/master/developer-guides/livechat-api |
# Conflicts: # package-lock.json
@sampaiodiego, |
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.
}, | ||
|
||
registerGuest(data) { | ||
if (!(typeof data === 'object')) { |
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.
please change to if (typeof data !== 'object') {
to help readability
@@ -38,6 +55,59 @@ export default { | |||
return this.token.get(); | |||
}, | |||
|
|||
setToken(token) { | |||
if ((!token) || (token == this.token.get())) { |
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 don't need to use this much parenthesis.. without them the code looks much clearer:
if (!token || token === this.token.get()) {
@@ -11,7 +11,8 @@ Meteor.methods({ | |||
RocketChat.models.Messages.keepHistoryForToken(token); | |||
|
|||
return { | |||
userId | |||
userId, | |||
token |
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.
on pull request #10767 this method will return the whole visitor object, I think you can to the same here (it should avoid future conflicts)
Livechat.guestName = null; | ||
Livechat.guestEmail = null; | ||
|
||
msgStream.unsubscribe('room-messages'); |
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.
this does not have the desired effect. on my tests after changing the token using setGuestToken
, I'm still receiving messages from the old room/token and being notified as well.
…at/Rocket.Chat into livechat-additional-iframe-apis
# Conflicts: # packages/rocketchat-livechat/server/methods/registerGuest.js
@sampaiodiego, the changes requested has been submitted. |
|
||
this.guestName = new ReactiveVar(null); | ||
this.autorun(() => { | ||
this.guestName.set(Livechat.guestName); |
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.
any reason to not use Livechat.guestName
directly on helper instead of creating this reactive var?
} | ||
}, | ||
getName() { | ||
return Template.instance().guestName.get(); |
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 can use Livechat.guestName
directly here, instead of using the reactive var
@sampaiodiego, I fixed the usage of |
@@ -62,7 +62,7 @@ Template.messages.helpers({ | |||
}; | |||
}, | |||
agentData() { | |||
const agent = Livechat.agent; | |||
const agent = Template.instance().agentData.get(); |
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.
I think this is the same case as Livechat.guestName
I've talked before (sry for not have seen this before). Any reason to use a ReactiveVar
here instead of keeping Livechat. agent
?
Hi @sampaiodiego! |
Please, we need this too: |
Closes #10866
This PR adds new Livechat iFrame API's, as described below:
setGuestToken(token):
Using this method a new Livechat session will be created using a
external token
(e.g.):RocketChat(function() { this.setGuestToken('FHwaLnp8fzjMupSAj'); });
setGuestName(name):
This method assigns a name to the Livechat active session visitor. If the visitor is already registered, its name will be updated in the database. If the visitor is not yet registered, its name will be assigned when the registration method is called.(e.g.):
RocketChat(function() { this.setGuestName('Rocket.Chat visitor name'); });
setGuestEmail(email):
This method assigns an email to the Livechat active session visitor. If the visitor is already registered, its email will be updated in the database. If the visitor is not yet registered, its email will be assigned when the registration method is called.(e.g.):
RocketChat(function() { this.setGuestEmail('rocket@rocket.chat'); });
registerGuest(data):
This method checks if there is a Livechat visitor with the same token passed by the object. If a Livechat visitor does not exist, a new Livechat visitor will be created or, if one exists, will be updated. After that, a new Livechat session will be started.(e.g.):
RocketChat(function() { this.registerGuest({token: 'pSjpaw46CeL6Zu9f9', name: 'Rocket.Chat visitor name', email: 'rocket@rocket.chat'}); });
Or without a token:
RocketChat(function() { this.registerGuest({name: 'Rocket.Chat visitor name', email: 'rocket@rocket.chat'}); });