Send profile with every RPC response.
This commit is contained in:
5
api.py
5
api.py
@@ -37,13 +37,11 @@ def CreateChannel(google_user, client, client_address, instance_id, args):
|
|||||||
if google_user:
|
if google_user:
|
||||||
events.append({
|
events.append({
|
||||||
'event_type': 'login',
|
'event_type': 'login',
|
||||||
'profile': str(models.Client.profile.get_value_for_datastore(client)),
|
|
||||||
'google_user': google_user.email(),
|
'google_user': google_user.email(),
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
events.append({
|
events.append({
|
||||||
'event_type': 'logout',
|
'event_type': 'logout',
|
||||||
'profile': str(models.Client.profile.get_value_for_datastore(client)),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -195,8 +193,11 @@ class APIWrapper(webapp2.RequestHandler):
|
|||||||
@security.weak_security_checks
|
@security.weak_security_checks
|
||||||
@session.session_required
|
@session.session_required
|
||||||
def post(self):
|
def post(self):
|
||||||
|
profile_str = str(
|
||||||
|
models.Client.profile.get_value_for_datastore(self.client))
|
||||||
ret = {
|
ret = {
|
||||||
'status': 'ok',
|
'status': 'ok',
|
||||||
|
'profile': profile_str,
|
||||||
'responses': [],
|
'responses': [],
|
||||||
'events': [],
|
'events': [],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,7 +172,6 @@ Cosmopolite.typeEvent_;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{event_type: string,
|
* @typedef {{event_type: string,
|
||||||
* profile: string,
|
|
||||||
* google_user: string}}
|
* google_user: string}}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
@@ -180,8 +179,7 @@ Cosmopolite.typeLogin_;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{event_type: string,
|
* @typedef {{event_type: string}}
|
||||||
* profile: string}}
|
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
Cosmopolite.typeLogout_;
|
Cosmopolite.typeLogout_;
|
||||||
@@ -842,6 +840,14 @@ Cosmopolite.prototype.onRPCResponse_ =
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @type {string} */
|
||||||
|
this.profile_ = data['profile'];
|
||||||
|
this.trackEvent('set', 'userId', this.profile_);
|
||||||
|
var resolve;
|
||||||
|
while (resolve = this.profilePromises_.pop()) {
|
||||||
|
resolve(this.profile_);
|
||||||
|
}
|
||||||
|
|
||||||
for (var i = 0; i < data['responses'].length; i++) {
|
for (var i = 0; i < data['responses'].length; i++) {
|
||||||
var response = data['responses'][i];
|
var response = data['responses'][i];
|
||||||
if (response['result'] == 'retry') {
|
if (response['result'] == 'retry') {
|
||||||
@@ -1298,15 +1304,6 @@ Cosmopolite.prototype.onServerEvent_ = function(e) {
|
|||||||
if (this.shutdown_) {
|
if (this.shutdown_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (e['profile']) {
|
|
||||||
/** @type {string} */
|
|
||||||
this.profile_ = e['profile'];
|
|
||||||
this.trackEvent('set', 'userId', this.profile_);
|
|
||||||
this.profilePromises_.forEach(function(resolve) {
|
|
||||||
resolve(this.profile_);
|
|
||||||
}, this);
|
|
||||||
this.profilePromises_.length = 0;
|
|
||||||
}
|
|
||||||
switch (e['event_type']) {
|
switch (e['event_type']) {
|
||||||
case 'close':
|
case 'close':
|
||||||
this.onClose_();
|
this.onClose_();
|
||||||
|
|||||||
Reference in New Issue
Block a user