]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/OStatusPlugin.php
Converted all ActivityObject::fromProfile to $profile->asActivityObject
[quix0rs-gnu-social.git] / plugins / OStatus / OStatusPlugin.php
index 42ee9a43efb86a5299adfff1dfd5249d1e0f4be8..7b19e386e6a04b3290c12e47aadcbd1eac800c2b 100644 (file)
@@ -691,8 +691,8 @@ class OStatusPlugin extends Plugin
                                $profile->getBestName(),
                                $other->getBestName());
 
-        $act->actor   = ActivityObject::fromProfile($profile);
-        $act->object  = ActivityObject::fromProfile($other);
+        $act->actor   = $profile->asActivityObject();
+        $act->object  = $other->asActivityObject();
 
         $oprofile->notifyActivity($act, $profile);
 
@@ -728,7 +728,7 @@ class OStatusPlugin extends Plugin
                                 $group->id,
                                 common_date_iso8601(time()));
 
-        $act->actor = ActivityObject::fromProfile($profile);
+        $act->actor = $profile->asActivityObject();
         $act->verb = ActivityVerb::JOIN;
         $act->object = $oprofile->asActivityObject();
 
@@ -782,7 +782,7 @@ class OStatusPlugin extends Plugin
                                 $group->id,
                                 common_date_iso8601(time()));
 
-        $act->actor = ActivityObject::fromProfile($member);
+        $act->actor = $member->asActivityObject();
         $act->verb = ActivityVerb::LEAVE;
         $act->object = $oprofile->asActivityObject();
 
@@ -828,7 +828,7 @@ class OStatusPlugin extends Plugin
                                 $peopletag->id,
                                 common_date_iso8601(time()));
 
-        $act->actor = ActivityObject::fromProfile($sub);
+        $act->actor = $sub->asActivityObject();
         $act->verb = ActivityVerb::FOLLOW;
         $act->object = $oprofile->asActivityObject();
 
@@ -880,7 +880,7 @@ class OStatusPlugin extends Plugin
                                 $peopletag->id,
                                 common_date_iso8601(time()));
 
-        $act->actor = ActivityObject::fromProfile($member);
+        $act->actor = $member->asActivityObject();
         $act->verb = ActivityVerb::UNFOLLOW;
         $act->object = $oprofile->asActivityObject();
 
@@ -973,8 +973,8 @@ class OStatusPlugin extends Plugin
                                 $tagged->getBestName(),
                                 $plist->getBestName());
 
-        $act->actor  = ActivityObject::fromProfile($tagger);
-        $act->objects = array(ActivityObject::fromProfile($tagged));
+        $act->actor  = $tagger->asActivityObject();
+        $act->objects = array($tagged->asActivityObject());
         $act->target = ActivityObject::fromPeopletag($plist);
 
         $oprofile->notifyDeferred($act, $tagger);
@@ -1024,8 +1024,8 @@ class OStatusPlugin extends Plugin
                                 $tagged->getBestName(),
                                 $plist->getBestName());
 
-        $act->actor  = ActivityObject::fromProfile($tagger);
-        $act->objects = array(ActivityObject::fromProfile($tagged));
+        $act->actor  = $tagger->asActivityObject();
+        $act->objects = array($tagged->asActivityObject());
         $act->target = ActivityObject::fromPeopletag($plist);
 
         $oprofile->notifyDeferred($act, $tagger);
@@ -1073,7 +1073,7 @@ class OStatusPlugin extends Plugin
                                $profile->getBestName(),
                                $notice->getUrl());
 
-        $act->actor   = ActivityObject::fromProfile($profile);
+        $act->actor   = $profile->asActivityObject();
         $act->object  = ActivityObject::fromNotice($notice);
 
         $oprofile->notifyActivity($act, $profile);
@@ -1191,7 +1191,7 @@ class OStatusPlugin extends Plugin
         $act->content = sprintf(_m('%s has updated their profile page.'),
                                $profile->getBestName());
 
-        $act->actor   = ActivityObject::fromProfile($profile);
+        $act->actor   = $profile->asActivityObject();
         $act->object  = $act->actor;
 
         while ($oprofile->fetch()) {
@@ -1360,4 +1360,24 @@ class OStatusPlugin extends Plugin
 
         return true;
     }
+
+    public function onGetLocalAttentions(Profile $actor, array $attention_uris, array &$mentions, array &$groups)
+    {
+        list($mentions, $groups) = Ostatus_profile::filterAttention($actor, $attention_uris);
+    }
+
+    // FIXME: Maybe this shouldn't be so authoritative that it breaks other remote profile lookups?
+    static public function onCheckActivityAuthorship(Activity $activity, Profile &$profile)
+    {
+        try {
+            $oprofile = Ostatus_profile::getFromProfile($profile);
+            $oprofile = $oprofile->checkAuthorship($activity);
+            $profile = $oprofile->localProfile();
+        } catch (Exception $e) {
+            common_log(LOG_ERR, 'Could not get a profile or check authorship ('.get_class($e).': "'.$e->getMessage().'")');
+            $profile = null;
+            return false;
+        }
+        return true;
+    }
 }