]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Notice.php
Merge branch '1.0.x' into activity
[quix0rs-gnu-social.git] / classes / Notice.php
index 3ea7a2d497dcbe7d8ebc35ccc2f7d449fa712612..e029880f8d2c6900ced425878479c26ceef3258c 100644 (file)
@@ -49,7 +49,7 @@ define('NOTICE_CACHE_WINDOW', CachingNoticeStream::CACHE_WINDOW);
 
 define('MAX_BOXCARS', 128);
 
-class Notice extends Memcached_DataObject
+class Notice extends Managed_DataObject
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
@@ -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)
 
@@ -84,6 +85,55 @@ class Notice extends Memcached_DataObject
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
 
+    public static function schemaDef()
+    {
+        return array(
+            'fields' => array(
+                'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'),
+                'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'who made the update'),
+                'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier, usually a tag URI'),
+                'content' => array('type' => 'text', 'description' => 'update content'),
+                'rendered' => array('type' => 'text', 'description' => 'HTML version of the content'),
+                'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL of any attachment (image, video, bookmark, whatever)'),
+                'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
+                'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
+                'reply_to' => array('type' => 'int', 'description' => 'notice replied to (usually a guess)'),
+                'is_local' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'notice was generated by a user'),
+                'source' => array('type' => 'varchar', 'length' => 32, 'description' => 'source of comment, like "web", "im", or "clientname"'),
+                'conversation' => array('type' => 'int', 'description' => 'id of root notice in this conversation'),
+                'lat' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'latitude'),
+                'lon' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'longitude'),
+                'location_id' => array('type' => 'int', 'description' => 'location id if possible'),
+                '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'),
+                'scope' => array('type' => 'int',
+                                 'default' => '1',
+                                 'description' => 'bit map for distribution scope; 0 = everywhere; 1 = this server only; 2 = addressees; 4 = followers'),
+            ),
+            'primary key' => array('id'),
+            'unique keys' => array(
+                'notice_uri_key' => array('uri'),
+            ),
+            'foreign keys' => array(
+                'notice_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
+                'notice_reply_to_fkey' => array('notice', array('reply_to' => 'id')),
+                'notice_conversation_fkey' => array('conversation', array('conversation' => 'id')), # note... used to refer to notice.id
+                'notice_repeat_of_fkey' => array('notice', array('repeat_of' => 'id')), # @fixme: what about repeats of deleted notices?
+            ),
+            'indexes' => array(
+                'notice_profile_id_idx' => array('profile_id', 'created', 'id'),
+                'notice_conversation_idx' => array('conversation'),
+                'notice_created_idx' => array('created'),
+                'notice_replyto_idx' => array('reply_to'),
+                'notice_repeatof_idx' => array('repeat_of'),
+            ),
+            'fulltext indexes' => array(
+                'content' => array('content'),
+            )
+        );
+    }
+    
        function multiGet($kc, $kvs, $skipNulls=true)
        {
                return Memcached_DataObject::multiGet('Notice', $kc, $kvs, $skipNulls);
@@ -264,6 +314,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 +328,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 +501,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 +1508,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?