]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Some better context for notices as arrays
authorEvan Prodromou <evan@e14n.com>
Fri, 7 Jun 2013 07:11:23 +0000 (03:11 -0400)
committerEvan Prodromou <evan@e14n.com>
Fri, 7 Jun 2013 07:11:23 +0000 (03:11 -0400)
classes/Notice.php
lib/activitycontext.php
lib/activityobject.php

index beb6c4fe6af101e4053c67b5b00132cbdb0824b8..abec8b7af4e719f305156a7f7afce4c79ed4d0c0 100644 (file)
@@ -1577,6 +1577,7 @@ class Notice extends Managed_DataObject
                 $rprofile = Profile::staticGet('id', $id);
                 if (!empty($rprofile)) {
                     $ctx->attention[] = $rprofile->getUri();
+                    $ctx->attentionType[$rprofile->getUri()] = ActivityObject::PERSON;
                 }
             }
 
@@ -1584,6 +1585,19 @@ class Notice extends Managed_DataObject
 
             foreach ($groups as $group) {
                 $ctx->attention[] = $group->getUri();
+                $ctx->attentionType[$group->getUri()] = ActivityObject::GROUP;
+            }
+
+            switch ($this->scope) {
+            case Notice::PUBLIC_SCOPE:
+                $ctx->attention[] = "http://activityschema.org/collection/public";
+                $ctx->attentionType["http://activityschema.org/collection/public"] = ActivityObject::COLLECTION;
+                break;
+            case Notice::FOLLOWER_SCOPE:
+                $surl = common_local_url("subscribers", array('nickname' => $profile->nickname));
+                $ctx->attention[] = $surl;
+                $ctx->attentionType[$surl] = ActivityObject::COLLECTION;
+                break;
             }
 
             // XXX: deprecated; use ActivityVerb::SHARE instead
index 2eff3fb15fb1605513681efd16f32d25ed75786c..e383b05734431c51dd1a6c554ccbfe6679ce941a 100644 (file)
@@ -38,9 +38,11 @@ class ActivityContext
     public $replyToUrl;
     public $location;
     public $attention = array();
+    public $attentionType = array();
     public $conversation;
     public $forwardID; // deprecated, use ActivityVerb::SHARE instead
     public $forwardUrl; // deprecated, use ActivityVerb::SHARE instead
+    public $scope;
 
     const THR     = 'http://purl.org/syndication/thread/1.0';
     const GEORSS  = 'http://www.georss.org/georss';
@@ -167,10 +169,14 @@ class ActivityContext
         $tos = array();
 
         foreach ($this->attention as $attnUrl) {
+            if (array_key_exists($attnUrl, $this->attentionType)) {
+                $type = ActivityObject::canonicalType($this->attentionType[$attnUrl]);
+            } else {
+                $type = ActivityObject::canonicalType(ActivityObject::PERSON);
+            }
             $to = array(
-                'objectType' => 'person',
-                'id'         => $attnUrl,
-                'url'        => $attnUrl
+                'objectType' => $type,
+                'id'         => $attnUrl
             );
             $tos[] = $to;
         }
index 97cf0f5d793b332b7174112774de91f76e7a19d9..1352b5bda82ca569ab67e64e7bd64aacbb00676a 100644 (file)
@@ -71,6 +71,7 @@ class ActivityObject
     const ACTIVITY = 'http://activitystrea.ms/schema/1.0/activity';
     const SERVICE   = 'http://activitystrea.ms/schema/1.0/service';
     const IMAGE     = 'http://activitystrea.ms/schema/1.0/image';
+    const COLLECTION = 'http://activitystrea.ms/schema/1.0/collection';
 
     // Atom elements we snarf
 
@@ -502,6 +503,10 @@ class ActivityObject
 
             $object->poco = PoCo::fromProfile($profile);
 
+            if ($profile->getUser()) {
+                $object->extra[] = array('followers', array('url' => common_local_url('subscribers', array('nickname' => $profile->nickname))));
+            }
+
             Event::handle('EndActivityObjectFromProfile', array($profile, &$object));
         }
 
@@ -737,7 +742,12 @@ class ActivityObject
             // downstreamDuplicates
 
             // id
-            $object['id'] = $this->id;
+
+            if ($this->id) {
+                $object['id'] = $this->id;
+            } else if ($this->link) {
+                $object['id'] = $this->link;
+            }
 
             if ($this->type == ActivityObject::PERSON
                 || $this->type == ActivityObject::GROUP) {