]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
More use of Profile, less User
authorMikael Nordfeldth <mmn@hethane.se>
Mon, 28 Jul 2014 07:25:05 +0000 (09:25 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Mon, 28 Jul 2014 07:34:46 +0000 (09:34 +0200)
classes/Message.php
classes/Notice.php
classes/Profile.php
lib/activitystreamjsondocument.php
lib/atomusernoticefeed.php
plugins/Activity/ActivityPlugin.php

index bc25b1b0b3acfd15e0727e3e6ebe6594e4b12777..cc605ab54f13da476e512c7c41150c6014237874 100644 (file)
@@ -184,7 +184,7 @@ class Message extends Managed_DataObject
             }
             
             $act->actor            = $profile->asActivityObject();
-            $act->actor->extra[]   = $profile->profileInfo(null);
+            $act->actor->extra[]   = $profile->profileInfo();
 
             $act->verb = ActivityVerb::POST;
 
index 89f41ad79b1335c5334ede77a45d5029f839b3ce..e9875d34240282162494bad51b7d00106b3f9688 100644 (file)
@@ -1737,12 +1737,12 @@ class Notice extends Managed_DataObject
     /**
      * Convert a notice into an activity for export.
      *
-     * @param User $cur Current user
+     * @param Profile $scoped   The currently logged in/scoped profile
      *
      * @return Activity activity object representing this Notice.
      */
 
-    function asActivity($cur=null)
+    function asActivity(Profile $scoped=null)
     {
         $act = self::cacheGet(Cache::codeKey('notice:as-activity:'.$this->id));
 
@@ -1766,14 +1766,14 @@ class Notice extends Managed_DataObject
             $profile = $this->getProfile();
 
             $act->actor            = $profile->asActivityObject();
-            $act->actor->extra[]   = $profile->profileInfo($cur);
+            $act->actor->extra[]   = $profile->profileInfo($scoped);
 
             $act->verb = $this->verb;
 
             if ($this->repeat_of) {
                 $repeated = Notice::getKV('id', $this->repeat_of);
                 if ($repeated instanceof Notice) {
-                    $act->objects[] = $repeated->asActivity($cur);
+                    $act->objects[] = $repeated->asActivity($scoped);
                 }
             } else {
                 $act->objects[] = $this->asActivityObject();
@@ -1912,10 +1912,10 @@ class Notice extends Managed_DataObject
     function asAtomEntry($namespace=false,
                          $source=false,
                          $author=true,
-                         $cur=null)
+                         Profile $scoped=null)
     {
-        $act = $this->asActivity($cur);
-        $act->extra[] = $this->noticeInfo($cur);
+        $act = $this->asActivity($scoped);
+        $act->extra[] = $this->noticeInfo($scoped);
         return $act->asString($namespace, $author, $source);
     }
 
@@ -1925,12 +1925,12 @@ class Notice extends Managed_DataObject
      * Clients use some extra notice info in the atom stream.
      * This gives it to them.
      *
-     * @param User $cur Current user
+     * @param Profile $scoped   The currently logged in/scoped profile
      *
      * @return array representation of <statusnet:notice_info> element
      */
 
-    function noticeInfo($cur)
+    function noticeInfo(Profile $scoped=null)
     {
         // local notice ID (useful to clients for ordering)
 
@@ -1956,9 +1956,7 @@ class Notice extends Managed_DataObject
 
         // favorite and repeated
 
-        $scoped = null;
-        if (!empty($cur)) {
-            $scoped = $cur->getProfile();
+        if ($scoped instanceof Profile) {
             $noticeInfoAttr['repeated'] = ($scoped->hasRepeated($this)) ? "true" : "false";
         }
 
index e0eb06956feae9f3fcceea150e609d6040eac599..94f83ab788a1ca388168d1bfb80dec1251c2ccb1 100644 (file)
@@ -1266,20 +1266,20 @@ class Profile extends Managed_DataObject
      * Clients use some extra profile info in the atom stream.
      * This gives it to them.
      *
-     * @param User $cur Current user
+     * @param Profile $scoped The currently logged in/scoped profile
      *
      * @return array representation of <statusnet:profile_info> element or null
      */
 
-    function profileInfo($cur)
+    function profileInfo(Profile $scoped=null)
     {
         $profileInfoAttr = array('local_id' => $this->id);
 
-        if ($cur != null) {
+        if ($scoped instanceof Profile) {
             // Whether the current user is a subscribed to this profile
-            $profileInfoAttr['following'] = $cur->isSubscribed($this) ? 'true' : 'false';
+            $profileInfoAttr['following'] = $scoped->isSubscribed($this) ? 'true' : 'false';
             // Whether the current user is has blocked this profile
-            $profileInfoAttr['blocking']  = $cur->hasBlocked($this) ? 'true' : 'false';
+            $profileInfoAttr['blocking']  = $scoped->hasBlocked($this) ? 'true' : 'false';
         }
 
         return array('statusnet:profile_info', $profileInfoAttr, null);
index ed3197bc7f723c792cc1af7853faa29b42815b4f..767fb5dff734d61b10d4f5c56589db70ff5eef9e 100644 (file)
@@ -141,7 +141,7 @@ class ActivityStreamJSONDocument extends JSONActivityCollection
         $cur = empty($this->cur) ? common_current_user() : $this->cur;
 
         $act          = $notice->asActivity($cur);
-        $act->extra[] = $notice->noticeInfo($cur);
+        $act->extra[] = $notice->noticeInfo($cur->getProfile());
         array_push($this->items, $act->asArray());
         $this->count++;
     }
index 567045ee869ba50026de6cbb62787d40e1a26b7b..56e97880b0a651e76aa0c20c62eb3d83a0d1cdca 100644 (file)
@@ -64,7 +64,7 @@ class AtomUserNoticeFeed extends AtomNoticeFeed
 
             $ao = $profile->asActivityObject();
 
-            array_push($ao->extra, $profile->profileInfo($cur));
+            array_push($ao->extra, $profile->profileInfo($cur->getProfile()));
 
             $this->addAuthorRaw($ao->asString('author'));
         }
index 99c0a246c6daaa66bae1974bbd2f9e7360a6c776..6dc9730544344b2d18c7739fe29f265112d53ea2 100644 (file)
@@ -317,7 +317,7 @@ class ActivityPlugin extends Plugin
                 $notice = Notice::getKV('id', $fave->notice_id);
                 if (!empty($notice)) {
                     $cur = common_current_user();
-                    $target = $notice->asActivity($cur);
+                    $target = $notice->asActivity($cur->getProfile());
                     if ($target->verb == ActivityVerb::POST) {
                         // "I like the thing you posted"
                         $activity->objects = $target->objects;