-
Notifications
You must be signed in to change notification settings - Fork 230
[WIP-GSoC-19] Store Livechat sessions on backend side #242
base: develop
Are you sure you want to change the base?
Conversation
Yes - this must not be automatically implemented, must have an off switch set to disabled by default, and be separately switchable from other information eg you may wish to collect an email address but NOT geo location data There must be some way to notify users of the data collection if it is enabled. |
41cf4dd
to
1608fba
Compare
src/lib/location.js
Outdated
* @returns {Object} | ||
*/ | ||
const locationPrimary = async(latitude, longitude) => { | ||
const { address } = await fetch(`https://nominatim.openstreetmap.org/reverse?format=json&lat=${ latitude }&lon=${ longitude }`, { |
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.
So this is going out to this api to grab location? This has to definitely be optional if done at all. Some serious privacy concerns around sending data like this out.
src/lib/location.js
Outdated
* @returns {Object} | ||
*/ | ||
const locationBackup = async() => { | ||
const location = await fetch('https://api.ipdata.co?api-key=test', { |
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.
Same here
Apart from truck loads of GDPR concerns here this, wording has a typo.
"Please enable your location to start chat. This is for your convenience only. Thanks" It also sounds like you are telling users that unless they enable location they cannot chat with you? I don't think so.
|
Signed-off-by: knrt10 <[email protected]>
Signed-off-by: knrt10 <[email protected]>
src/api.js
Outdated
|| queryString.parse(window.location.search).serverUrl | ||
|| (process.env.NODE_ENV === 'development' ? 'http://localhost:3000' : null); | ||
// eslint-disable-next-line import/no-absolute-path | ||
import LivechatClient from '/Users/knrt10/dev/openSource/RocketChat/Rocket.Chat.js.SDK/dist/lib/clients/Livechat'; |
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 you forget to remove this code before pushing your changes.
src/lib/location.js
Outdated
@@ -0,0 +1,290 @@ | |||
/* eslint-disable no-lonely-if */ | |||
/* eslint-disable no-alert */ | |||
import { getToken } from './main'; |
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 is a clone from the userPresence
lib, you don't need a new lib to do the same things, it does not make sense.
You can do what you want by calling the new methods related to session stuff within the userPresence
lib.
Please, remove this file and move the new methods to a helper
lib.
src/routes/Chat/container.js
Outdated
@@ -106,13 +106,15 @@ export class ChatContainer extends Component { | |||
this.stopTypingDebounced.stop(); | |||
await Promise.all([ | |||
this.stopTyping({ rid, username: user.username }), | |||
Livechat.updateSessionStatus('online', 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.
Why call this method here?
We have a specific lib to deal with user status.
@@ -30,6 +30,7 @@ export class RegisterContainer extends Component { | |||
await dispatch({ loading: true, department }); | |||
try { | |||
await Livechat.grantVisitor({ visitor: { ...fields, token } }); | |||
await Livechat.updateVisitorSessionOnRegister({ visitor: { ...fields, 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.
Why not just one method to update the livechat session?
You just need one method, you can pass specific data as parameters.
src/components/App/index.js
Outdated
@@ -149,6 +151,7 @@ export class App extends Component { | |||
async finalize() { | |||
CustomFields.reset(); | |||
userPresence.reset(); | |||
userSessionPresence.reset(); |
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.
We don't need this lib.
@knrt10
Please, keep in mind you need to reduce the complexity in this PR, one suggestion is to use just one method to handle the session data. |
Signed-off-by: knrt10 <[email protected]>
@renatobecker please review