Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

handle protected tweets

  • Loading branch information...
commit 669c278f7460bad3cee3c0e0cb55562a23343432 1 parent 6a788c2
@jchris authored
Showing with 24 additions and 7 deletions.
  1. +6 −0 README.md
  2. +9 −4 node/twebzbot.js
  3. +9 −3 validate_doc_update.js
View
6 README.md
@@ -4,6 +4,12 @@ This app basically doesn't work yet. But it will. And it will be awesome!
Watch this space for updates.
+twebz user
+user dbs
+protected tweets
+config.json
+globalWordCount
+
## Generated by CouchApp
CouchApps are web applications which can be served directly from [CouchDB](http://couchdb.apache.org). This gives them the nice property of replicating just like any other data stored in CouchDB. They are also simple to write as they can use the built-in jQuery libraries and plugins that ship with CouchDB.
View
13 node/twebzbot.js
@@ -561,11 +561,16 @@ config_db.getDoc(twebz.twitter_keys_docid, function(er, doc) {
// listen for _changes on twebz db
function getSince(cb) {
- db.view("twebz","seq", {}, function(er, resp) {
- if (resp.rows.length > 0) {
- cb(resp.rows[0].value.max);
+ db.view("twebz","seq", {random : Math.random()}, function(er, resp) {
+ if (er) {
+ log("getSince")
+ log(er)
} else {
- cb(0);
+ if (resp.rows && resp.rows.length > 0) {
+ cb(resp.rows[0].value.max);
+ } else {
+ cb(0);
+ }
}
});
};
View
12 validate_doc_update.js
@@ -1,8 +1,14 @@
-function() {
+function(newDoc, oldDoc, userCtx, secObj) {
+ // protected tweets cannot be saved
+ if (newDoc.text && newDoc.user && newDoc.user["protected"]) {
+ if (!(secObj.readers && (secObj.readers.names || secObj.readers.roles)) ||
+ (secObj.readers.names.length + secObj.readers.roles.length) == 0) {
+ throw({forbidden : "you must have a read-restricted database to save protected tweets"});
+ }
+ }
return true;
// validations todo
// users can only create a link-account doc for their own self
// only admin or twebz user can edit twebz-status doc
- // protected tweets cannot be saved
// state machine ordering (especially state can't be changed to unsent)
-};
+};
Please sign in to comment.
Something went wrong with that request. Please try again.