]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Make sure reshare notices get the right object_type and verb
authorEvan Prodromou <evan@status.net>
Wed, 7 Sep 2011 22:34:31 +0000 (18:34 -0400)
committerEvan Prodromou <evan@status.net>
Wed, 7 Sep 2011 22:34:31 +0000 (18:34 -0400)
scripts/upgrade.php

index 759c2df58f2453408713dd7889976524b584fa2f..af89760f705da91182378762e582502b609fcd75 100644 (file)
@@ -44,6 +44,7 @@ function main()
     initInbox();
     fixupGroupURI();
     initLocalGroup();
+    initNoticeReshare();
 }
 
 function tableDefs()
@@ -258,4 +259,28 @@ function initLocalGroup()
     printfnq("DONE.\n");
 }
 
+function initNoticeReshare()
+{
+    printfnq("Ensuring all reshares have the correct verb and object-type...");
+    
+    $notice = new Notice();
+    $notice->whereAdd('repeat_of is not null');
+    $notice->whereAdd('(verb != "'.ActivityVerb::SHARE.'" OR object_type != "'.ActivityObject::ACTIVITY.'")');
+
+    if ($notice->find()) {
+        while ($notice->fetch()) {
+            try {
+                $orig = Notice::staticGet('id', $notice->id);
+                $notice->verb = ActivityVerb::SHARE;
+                $notice->object_type = ActivityObject::ACTIVITY;
+                $notice->update($orig);
+            } catch (Exception $e) {
+                printfv("Error updating verb and object_type for {$notice->id}:" . $e->getMessage());
+            }
+        }
+    }
+
+    printfnq("DONE.\n");
+}
+
 main();