From 48bb784400dd9569739ac68e7c87a7db427ef018 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 22 Aug 2011 16:02:14 -0400 Subject: [PATCH] add a verb column to the notice table --- classes/Notice.php | 30 ++++++++++++++++++++---------- db/core.php | 1 + 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index 3ea7a2d497..0305baea34 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -72,6 +72,7 @@ class Notice extends Memcached_DataObject public $location_id; // int(4) public $location_ns; // int(4) public $repeat_of; // int(4) + public $verb; // varchar(255) public $object_type; // varchar(255) public $scope; // int(4) @@ -264,6 +265,7 @@ class Notice extends Memcached_DataObject * notice in place of extracting links from content * boolean 'distribute' whether to distribute the notice, default true * string 'object_type' URL of the associated object type (default ActivityObject::NOTE) + * string 'verb' URL of the associated verb (default ActivityVerb::POST) * int 'scope' Scope bitmask; default to SITE_SCOPE on private sites, 0 otherwise * * @fixme tag override @@ -277,7 +279,9 @@ class Notice extends Memcached_DataObject 'reply_to' => null, 'repeat_of' => null, 'scope' => null, - 'distribute' => true); + 'distribute' => true, + 'object_type' => null, + 'verb' => null); if (!empty($options) && is_array($options)) { $options = array_merge($defaults, $options); @@ -448,6 +452,17 @@ class Notice extends Memcached_DataObject $notice->rendered = common_render_content($final, $notice); } + if (empty($verb)) { + if (!empty($notice->repeat_of)) { + $notice->verb = ActivityVerb::SHARE; + $notice->object_type = ActivityVerb::ACTIVITY; + } else { + $notice->verb = ActivityVerb::POST; + } + } else { + $notice->verb = $verb; + } + if (empty($object_type)) { $notice->object_type = (empty($notice->reply_to)) ? ActivityObject::NOTE : ActivityObject::COMMENT; } else { @@ -1444,18 +1459,13 @@ class Notice extends Memcached_DataObject $act->actor = ActivityObject::fromProfile($profile); $act->actor->extra[] = $profile->profileInfo($cur); - if ($this->repeat_of) { + $act->verb = $this->verb; + if ($this->repeat_of) { $repeated = Notice::staticGet('id', $this->repeat_of); - - $act->verb = ActivityVerb::SHARE; - $act->objects[] = $repeated->asActivity($cur); - + $act->objects[] = $repeated->asActivity($cur); } else { - - $act->verb = ActivityVerb::POST; - $act->objects[] = ActivityObject::fromNotice($this); - + $act->objects[] = ActivityObject::fromNotice($this); } // XXX: should this be handled by default processing for object entry? diff --git a/db/core.php b/db/core.php index a9632fe8d4..7297081079 100644 --- a/db/core.php +++ b/db/core.php @@ -201,6 +201,7 @@ $schema['notice'] = array( 'location_ns' => array('type' => 'int', 'description' => 'namespace for location'), 'repeat_of' => array('type' => 'int', 'description' => 'notice this is a repeat of'), 'object_type' => array('type' => 'varchar', 'length' => 255, 'description' => 'URI representing activity streams object type', 'default' => 'http://activitystrea.ms/schema/1.0/note'), + 'verb' => array('type' => 'varchar', 'length' => 255, 'description' => 'URI representing activity streams verb', 'default' => 'http://activitystrea.ms/schema/1.0/post'), 'scope' => array('type' => 'int', 'default' => '1', 'description' => 'bit map for distribution scope; 0 = everywhere; 1 = this server only; 2 = addressees; 4 = followers'), -- 2.39.5