]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Deletes now federated. But might not be handled properly
authorMikael Nordfeldth <mmn@hethane.se>
Sat, 3 Oct 2015 12:39:49 +0000 (14:39 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Sat, 3 Oct 2015 12:39:49 +0000 (14:39 +0200)
classes/Notice.php
plugins/ActivityModeration/ActivityModerationPlugin.php
plugins/ActivityModeration/classes/Deleted_notice.php

index 7a3dc2bc0f4eb9dcfc160fe5b4a8b2f5b57edc24..1d9823c79cb429ee160080d2fda172908f0fb6d3 100644 (file)
@@ -286,6 +286,12 @@ class Notice extends Managed_DataObject
                 : $this->object_type;
     }
 
+    // activity plugins tend to use this function instead, but it's the same
+    public function getObjectType()
+    {
+        return $this->get_object_type();
+    }
+
     public static function getByUri($uri)
     {
         $notice = new Notice();
index 64e065d305bee23a70b6e95d2e6f97c1472f0260..dc21b115526e7556c08102409c38736e241ab317 100644 (file)
@@ -96,7 +96,7 @@ class ActivityModerationPlugin extends ActivityVerbHandlerPlugin
 
         $deleted->id            = $target->getID();
         $deleted->profile_id    = $target->getProfile()->getID();
-        $deleted->uri           = Deleted_notice::newUri($target->getProfile(), $target);
+        $deleted->uri           = $act->id;
         $deleted->act_uri       = $target->getUri();
         $deleted->act_created   = $target->created;
         $deleted->created       = common_sql_now();
@@ -112,6 +112,25 @@ class ActivityModerationPlugin extends ActivityVerbHandlerPlugin
         return $deleted;
     }
 
+    // FIXME: Put this in lib/activityhandlerplugin.php when we're ready
+    //          with the other microapps/activityhandlers as well.
+    //          Also it should be StartNoticeAsActivity (with a prepped Activity, including ->context etc.)
+    public function onEndNoticeAsActivity(Notice $stored, Activity $act, Profile $scoped=null)
+    {
+        if (!$this->isMyNotice($stored)) {
+            return true;
+        }
+
+        common_debug('Extending activity '.$stored->id.' with '.get_called_class());
+        $this->extendActivity($stored, $act, $scoped);
+        return false;
+    }
+
+    public function extendActivity(Notice $stored, Activity $act, Profile $scoped=null)
+    {
+        Deleted_notice::extendActivity($stored, $act, $scoped);
+    }
+
     public function activityObjectFromNotice(Notice $notice)
     {
         $object = Deleted_notice::fromStored($notice);
index e3723a329f646f27a89001f592adab7988d669ac..c4f12b14b0a3c5cb2241c09a0c6234891522a9d5 100644 (file)
@@ -69,10 +69,7 @@ class Deleted_notice extends Managed_DataObject
         $act->type = ActivityObject::ACTIVITY;
         $act->verb = ActivityVerb::DELETE;
         $act->time = time();
-        $act->id   = TagURI::mint('deleted_notice:%d:%d:%s',
-                            $actor->getID(),
-                            $notice->getID(),
-                            common_date_iso8601(common_sql_now()));
+        $act->id   = self::newUri($actor, $notice);
 
         $act->content = sprintf(_m('<a href="%1$s">%2$s</a> deleted notice <a href="%3$s">{{%4$s}}</a>.'),
                             htmlspecialchars($actor->getUrl()),
@@ -153,7 +150,6 @@ class Deleted_notice extends Managed_DataObject
         $actobj->actor = $this->getActorObject();
         $actobj->target = new ActivityObject();
         $actobj->target->id = $this->getTargetUri();
-        $actobj->target->type = ActivityUtils::resolveUri(self::getObjectType());
         $actobj->objects = array(clone($actobj->target));
         $actobj->verb = ActivityVerb::DELETE;
         $actobj->title = ActivityUtils::verbToTitle($actobj->verb);
@@ -168,6 +164,17 @@ class Deleted_notice extends Managed_DataObject
         return $actobj;
     }
 
+    static public function extendActivity(Notice $stored, Activity $act, Profile $scoped=null)
+    {
+        $object = self::fromStored($stored);
+
+        $act->target = $object->asActivityObject();
+        $act->objects = array(clone($act->target));
+
+        $act->context->replyToID = $object->getTargetUri();
+        $act->title = ActivityUtils::verbToTitle($act->verb);
+    }
+
     static function newUri(Profile $actor, Managed_DataObject $object, $created=null)
     {
         if (is_null($created)) {
@@ -175,7 +182,7 @@ class Deleted_notice extends Managed_DataObject
         }
         return TagURI::mint(strtolower(get_called_class()).':%d:%s:%d:%s',
                                         $actor->getID(),
-                                        ActivityUtils::resolveUri(self::getObjectType(), true),
+                                        ActivityUtils::resolveUri($object->getObjectType(), true),
                                         $object->getID(),
                                         common_date_iso8601($created));
     }