From d3d499879c4d01bde46033a3a98f9190ea18cb63 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 16 Jun 2010 14:29:24 -0700 Subject: - More useful group info from api/statusnet/group/show - Add statusnet:group_info tag to group Atom feeds --- classes/User_group.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'classes') diff --git a/classes/User_group.php b/classes/User_group.php index 110f08301..e04c46626 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -154,6 +154,21 @@ class User_group extends Memcached_DataObject return $members; } + function getMemberCount() + { + // XXX: WORM cache this + + $members = $this->getMembers(); + $member_count = 0; + + /** $member->count() doesn't work. */ + while ($members->fetch()) { + $member_count++; + } + + return $member_count; + } + function getAdmins($offset=0, $limit=null) { $qry = -- cgit v1.2.3-54-g00ecf From b66709215309126969104ad114874360785f3d57 Mon Sep 17 00:00:00 2001 From: James Walker Date: Thu, 17 Jun 2010 13:44:17 -0400 Subject: adding a Status_network::updateKeys() method, since DB_DataObject update doesn't do keys. --- classes/Status_network.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'classes') diff --git a/classes/Status_network.php b/classes/Status_network.php index 4a1f2c374..64016dd79 100644 --- a/classes/Status_network.php +++ b/classes/Status_network.php @@ -144,6 +144,35 @@ class Status_network extends Safe_DataObject return parent::update($orig); } + /** + * DB_DataObject doesn't allow updating keys (even non-primary) + */ + function updateKeys(&$orig) + { + $this->_connect(); + foreach (array('hostname', 'pathname') as $k) { + if (strcmp($this->$k, $orig->$k) != 0) { + $parts[] = $k . ' = ' . $this->_quote($this->$k); + } + } + if (count($parts) == 0) { + // No changes + return true; + } + + $toupdate = implode(', ', $parts); + + $table = common_database_tablename($this->tableName()); + $qry = 'UPDATE ' . $table . ' SET ' . $toupdate . + ' WHERE nickname = ' . $this->_quote($this->nickname); + $orig->decache(); + $result = $this->query($qry); + if ($result) { + $this->encache(); + } + return $result; + } + function delete() { $this->decache(); # while we still have the values! -- cgit v1.2.3-54-g00ecf From 105c1a22d6513d9a5cb33d6134a6d60d423ee462 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 17 Jun 2010 23:08:40 +0000 Subject: Include source client's related URL (if any) in source attribution for Atom notice feeds --- classes/Notice.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'classes') diff --git a/classes/Notice.php b/classes/Notice.php index 0838ca2a2..f8eda5777 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1238,9 +1238,25 @@ class Notice extends Memcached_DataObject $xs->element('published', null, common_date_w3dtf($this->created)); $xs->element('updated', null, common_date_w3dtf($this->created)); + $source = null; + + $ns = $this->getSource(); + + if ($ns) { + if (!empty($ns->name) && !empty($ns->url)) { + $source = '' + . htmlspecialchars($ns->name) + . ''; + } else { + $source = $ns->code; + } + } + $noticeInfoAttr = array( - 'local_id' => $this->id, // local notice ID (useful to clients for ordering) - 'source' => $this->source, // the client name (source attribution) + 'local_id' => $this->id, // local notice ID (useful to clients for ordering) + 'source' => $source, // the client name (source attribution) ); $ns = $this->getSource(); @@ -1252,8 +1268,8 @@ class Notice extends Memcached_DataObject if (!empty($cur)) { $noticeInfoAttr['favorite'] = ($cur->hasFave($this)) ? "true" : "false"; - $profile = $cur->getProfile(); - $noticeInfoAttr['repeated'] = ($profile->hasRepeated($this->id)) ? "true" : "false"; + $profile = $cur->getProfile(); + $noticeInfoAttr['repeated'] = ($profile->hasRepeated($this->id)) ? "true" : "false"; } if (!empty($this->repeat_of)) { -- cgit v1.2.3-54-g00ecf From 1eec7f779fc85b530907ea31deceadb2a30d7614 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Tue, 22 Jun 2010 16:28:06 -0700 Subject: - Add profile_info tag to Atom author - Normalize xmlns:statusnet links in the API --- classes/Notice.php | 4 ++-- classes/Profile.php | 10 +++++++++- lib/apiaction.php | 2 ++ lib/atomnoticefeed.php | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) (limited to 'classes') diff --git a/classes/Notice.php b/classes/Notice.php index f8eda5777..c752e35a7 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1190,7 +1190,7 @@ class Notice extends Memcached_DataObject 'xmlns:media' => 'http://purl.org/syndication/atommedia', 'xmlns:poco' => 'http://portablecontacts.net/spec/1.0', 'xmlns:ostatus' => 'http://ostatus.org/schema/1.0', - 'xmlns:statusnet' => 'http://status.net/ont/'); + 'xmlns:statusnet' => 'http://status.net/schema/api/1/'); } else { $attrs = array(); } @@ -1225,7 +1225,7 @@ class Notice extends Memcached_DataObject $xs->element('title', null, common_xml_safe_str($this->content)); if ($author) { - $xs->raw($profile->asAtomAuthor()); + $xs->raw($profile->asAtomAuthor($cur)); $xs->raw($profile->asActivityActor()); } diff --git a/classes/Profile.php b/classes/Profile.php index 54f557ea7..a303469e9 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -849,15 +849,23 @@ class Profile extends Memcached_DataObject * * Assumes that Atom has been previously set up as the base namespace. * + * @param Profile $cur the current authenticated user + * * @return string */ - function asAtomAuthor() + function asAtomAuthor($cur = null) { $xs = new XMLStringer(true); $xs->elementStart('author'); $xs->element('name', null, $this->nickname); $xs->element('uri', null, $this->getUri()); + if ($cur != null) { + $attrs = Array(); + $attrs['following'] = $cur->isSubscribed($this) ? 'true' : 'false'; + $attrs['blocking'] = $cur->hasBlocked($this) ? 'true' : 'false'; + $xs->element('statusnet:profile_info', $attrs, null); + } $xs->elementEnd('author'); return $xs->getString(); diff --git a/lib/apiaction.php b/lib/apiaction.php index 7cc473d51..226481778 100644 --- a/lib/apiaction.php +++ b/lib/apiaction.php @@ -208,11 +208,13 @@ class ApiAction extends Action // Is the requesting user following this user? $twitter_user['following'] = false; + $twitter_user['statusnet:blocking'] = false; $twitter_user['notifications'] = false; if (isset($this->auth_user)) { $twitter_user['following'] = $this->auth_user->isSubscribed($profile); + $twitter_user['statusnet:blocking'] = $this->auth_user->hasBlocked($profile); // Notifications on? $sub = Subscription::pkeyGet(array('subscriber' => diff --git a/lib/atomnoticefeed.php b/lib/atomnoticefeed.php index ef44de4b6..6ed803ce4 100644 --- a/lib/atomnoticefeed.php +++ b/lib/atomnoticefeed.php @@ -95,7 +95,7 @@ class AtomNoticeFeed extends Atom10Feed $this->addNamespace( 'statusnet', - 'http://status.net/ont/' + 'http://status.net/schema/api/1/' ); } -- cgit v1.2.3-54-g00ecf From f0c5e7eca3842411d4e3ee6efb3fd6ac0ad85f4a Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sat, 26 Jun 2010 15:07:32 -0400 Subject: Fix for bug #2382: releasing claim on failed queue item works again with DB-based queues. Warning: DB-based queue doesn't currently implement discarding of items after a retry limit. Failed items will be retried until they succeed. --- classes/Queue_item.php | 13 +++++++++++++ lib/dbqueuemanager.php | 4 +--- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'classes') diff --git a/classes/Queue_item.php b/classes/Queue_item.php index f83c2cef1..c7e17be6e 100644 --- a/classes/Queue_item.php +++ b/classes/Queue_item.php @@ -64,4 +64,17 @@ class Queue_item extends Memcached_DataObject $qi = null; return null; } + + /** + * Release a claimed item. + */ + function releaseCLaim() + { + // DB_DataObject doesn't let us save nulls right now + $sql = sprintf("UPDATE queue_item SET claimed=NULL WHERE id=%d", $this->id); + $this->query($sql); + + $this->claimed = null; + $this->encache(); + } } diff --git a/lib/dbqueuemanager.php b/lib/dbqueuemanager.php index 3032e4ec7..3dda9fd1a 100644 --- a/lib/dbqueuemanager.php +++ b/lib/dbqueuemanager.php @@ -135,9 +135,7 @@ class DBQueueManager extends QueueManager if (empty($qi->claimed)) { $this->_log(LOG_WARNING, "[$queue:item $qi->id] Ignoring failure for unclaimed queue item"); } else { - $orig = clone($qi); - $qi->claimed = null; - $qi->update($orig); + $qi->releaseClaim(); } $this->stats('error', $queue); -- cgit v1.2.3-54-g00ecf From dcfe5b24f6047aa830f107628aa3c10b9d292951 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 28 Jun 2010 15:20:50 -0400 Subject: Fix regression in 92ded7c6cb56056a89bc8b3caabd08049104898e: spewed PHP notices when checking for enclosures due to uninitialized variables. --- classes/File.php | 1 + 1 file changed, 1 insertion(+) (limited to 'classes') diff --git a/classes/File.php b/classes/File.php index 0cd31075d..0f230a6ee 100644 --- a/classes/File.php +++ b/classes/File.php @@ -302,6 +302,7 @@ class File extends Memcached_DataObject if(! isset($this->filename)){ $notEnclosureMimeTypes = array(null,'text/html','application/xhtml+xml'); + $mimetype = $this->mimetype; if($mimetype != null){ $mimetype = strtolower($this->mimetype); } -- cgit v1.2.3-54-g00ecf