Fixes for read/write ACLs on server and client side
This commit is contained in:
@@ -290,10 +290,10 @@ class Subject(db.Model):
|
|||||||
}
|
}
|
||||||
readable_only_by = Subject.readable_only_by.get_value_for_datastore(self)
|
readable_only_by = Subject.readable_only_by.get_value_for_datastore(self)
|
||||||
if readable_only_by:
|
if readable_only_by:
|
||||||
ret['readable_only_by'] = readable_only_by
|
ret['readable_only_by'] = str(readable_only_by)
|
||||||
writable_only_by = Subject.writable_only_by.get_value_for_datastore(self)
|
writable_only_by = Subject.writable_only_by.get_value_for_datastore(self)
|
||||||
if writable_only_by:
|
if writable_only_by:
|
||||||
ret['writable_only_by'] = writable_only_by
|
ret['writable_only_by'] = str(writable_only_by)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ Cosmopolite.prototype.subscribe = function(subject, opt_messages, opt_last_id) {
|
|||||||
/** @type {Cosmopolite.typeSubject} */
|
/** @type {Cosmopolite.typeSubject} */
|
||||||
var canonicalSubject = this.canonicalSubject_(subject);
|
var canonicalSubject = this.canonicalSubject_(subject);
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
var subjectString = JSON.stringify(canonicalSubject);
|
var subjectString = this.subjectString_(canonicalSubject);
|
||||||
if (!(subjectString in this.subscriptions_)) {
|
if (!(subjectString in this.subscriptions_)) {
|
||||||
this.subscriptions_[subjectString] = {
|
this.subscriptions_[subjectString] = {
|
||||||
'messages': [],
|
'messages': [],
|
||||||
@@ -316,7 +316,7 @@ Cosmopolite.prototype.unsubscribe = function(subject) {
|
|||||||
/** @type {Cosmopolite.typeSubject} */
|
/** @type {Cosmopolite.typeSubject} */
|
||||||
var canonicalSubject = this.canonicalSubject_(subject);
|
var canonicalSubject = this.canonicalSubject_(subject);
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
var subjectString = JSON.stringify(canonicalSubject);
|
var subjectString = this.subjectString_(canonicalSubject);
|
||||||
delete this.subscriptions_[subjectString];
|
delete this.subscriptions_[subjectString];
|
||||||
var args = {
|
var args = {
|
||||||
'subject': canonicalSubject
|
'subject': canonicalSubject
|
||||||
@@ -364,7 +364,7 @@ Cosmopolite.prototype.getMessages = function(subject) {
|
|||||||
/** @type {Cosmopolite.typeSubject} */
|
/** @type {Cosmopolite.typeSubject} */
|
||||||
var canonicalSubject = this.canonicalSubject_(subject);
|
var canonicalSubject = this.canonicalSubject_(subject);
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
var subjectString = JSON.stringify(canonicalSubject);
|
var subjectString = this.subjectString_(canonicalSubject);
|
||||||
return this.subscriptions_[subjectString].messages;
|
return this.subscriptions_[subjectString].messages;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -398,7 +398,7 @@ Cosmopolite.prototype.getPins = function(subject) {
|
|||||||
/** @type {Cosmopolite.typeSubject} */
|
/** @type {Cosmopolite.typeSubject} */
|
||||||
var canonicalSubject = this.canonicalSubject_(subject);
|
var canonicalSubject = this.canonicalSubject_(subject);
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
var subjectString = JSON.stringify(canonicalSubject);
|
var subjectString = this.subjectString_(canonicalSubject);
|
||||||
return this.subscriptions_[subjectString].pins;
|
return this.subscriptions_[subjectString].pins;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -546,6 +546,23 @@ Cosmopolite.prototype.canonicalSubject_ = function(subject) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stringify a subject for use as an object key.
|
||||||
|
*
|
||||||
|
* @param {Cosmopolite.typeSubject} subject
|
||||||
|
* @return {string}
|
||||||
|
* @const
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
Cosmopolite.prototype.subjectString_ = function(subject) {
|
||||||
|
return [
|
||||||
|
subject['name'],
|
||||||
|
subject['readable_only_by'],
|
||||||
|
subject['writable_only_by']
|
||||||
|
].toString();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback when a script loads.
|
* Callback when a script loads.
|
||||||
*
|
*
|
||||||
@@ -1042,13 +1059,15 @@ Cosmopolite.prototype.onLogout_ = function(e) {
|
|||||||
*/
|
*/
|
||||||
Cosmopolite.prototype.onMessage_ = function(e) {
|
Cosmopolite.prototype.onMessage_ = function(e) {
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
var subjectString = JSON.stringify(e['subject']);
|
var subjectString = this.subjectString_(e['subject']);
|
||||||
/** @type {Cosmopolite.typeSubscription_} */
|
/** @type {Cosmopolite.typeSubscription_} */
|
||||||
var subscription = this.subscriptions_[subjectString];
|
var subscription = this.subscriptions_[subjectString];
|
||||||
if (!subscription) {
|
if (!subscription) {
|
||||||
console.log(
|
console.log(
|
||||||
this.loggingPrefix_(),
|
this.loggingPrefix_(),
|
||||||
'message from unrecognized subject:', e);
|
'message from unrecognized subject:', e);
|
||||||
|
console.log(this.subscriptions_);
|
||||||
|
console.log(subjectString);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
@@ -1088,7 +1107,7 @@ Cosmopolite.prototype.onMessage_ = function(e) {
|
|||||||
*/
|
*/
|
||||||
Cosmopolite.prototype.onPin_ = function(e) {
|
Cosmopolite.prototype.onPin_ = function(e) {
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
var subjectString = JSON.stringify(e['subject']);
|
var subjectString = this.subjectString_(e['subject']);
|
||||||
/** @type {Cosmopolite.typeSubscription_} */
|
/** @type {Cosmopolite.typeSubscription_} */
|
||||||
var subscription = this.subscriptions_[subjectString];
|
var subscription = this.subscriptions_[subjectString];
|
||||||
if (!subscription) {
|
if (!subscription) {
|
||||||
@@ -1122,7 +1141,7 @@ Cosmopolite.prototype.onPin_ = function(e) {
|
|||||||
*/
|
*/
|
||||||
Cosmopolite.prototype.onUnpin_ = function(e) {
|
Cosmopolite.prototype.onUnpin_ = function(e) {
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
var subjectString = JSON.stringify(e['subject']);
|
var subjectString = this.subjectString_(e['subject']);
|
||||||
/** @type {Cosmopolite.typeSubscription_} */
|
/** @type {Cosmopolite.typeSubscription_} */
|
||||||
var subscription = this.subscriptions_[subjectString];
|
var subscription = this.subscriptions_[subjectString];
|
||||||
if (!subscription) {
|
if (!subscription) {
|
||||||
|
|||||||
Reference in New Issue
Block a user