Merge pull request #907 from annando/twitter-logging
[friendica-addons.git/.git] / twitter / twitter.php
index c4a1a57..4510cae 100644 (file)
@@ -85,6 +85,7 @@ use Friendica\Model\Item;
 use Friendica\Model\ItemContent;
 use Friendica\Model\User;
 use Friendica\Object\Image;
+use Friendica\Protocol\Activity;
 use Friendica\Util\ConfigFileLoader;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
@@ -556,11 +557,11 @@ function twitter_post_hook(App $a, array &$b)
                }
        }
 
-       if (($b['verb'] == ACTIVITY_POST) && $b['deleted']) {
+       if (($b['verb'] == Activity::POST) && $b['deleted']) {
                twitter_action($a, $b["uid"], substr($orig_post["uri"], 9), "delete");
        }
 
-       if ($b['verb'] == ACTIVITY_LIKE) {
+       if ($b['verb'] == Activity::LIKE) {
                Logger::log("twitter_post_hook: parameter 2 " . substr($b["thr-parent"], 9), Logger::DEBUG);
                if ($b['deleted']) {
                        twitter_action($a, $b["uid"], substr($b["thr-parent"], 9), "unlike");
@@ -1343,7 +1344,7 @@ function twitter_media_entities($post, array &$postarray)
                                        $media[$medium->url] .= "\n[img]" . $medium->media_url_https . '[/img]';
                                }
 
-                               $postarray['object-type'] = ACTIVITY_OBJ_IMAGE;
+                               $postarray['object-type'] = Activity\ObjectType::IMAGE;
                                break;
                        case 'video':
                        case 'animated_gif':
@@ -1354,7 +1355,7 @@ function twitter_media_entities($post, array &$postarray)
                                        $media[$medium->url] .= "\n[img]" . $medium->media_url_https . '[/img]';
                                }
 
-                               $postarray['object-type'] = ACTIVITY_OBJ_VIDEO;
+                               $postarray['object-type'] = Activity\ObjectType::VIDEO;
                                if (is_array($medium->video_info->variants)) {
                                        $bitrate = 0;
                                        // We take the video with the highest bitrate
@@ -1411,11 +1412,11 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
                        $postarray['thr-parent'] = $parent_item['uri'];
                        $postarray['parent-uri'] = $parent_item['parent-uri'];
                        $postarray['parent'] = $parent_item['parent'];
-                       $postarray['object-type'] = ACTIVITY_OBJ_COMMENT;
+                       $postarray['object-type'] = Activity\ObjectType::COMMENT;
                } else {
                        $postarray['thr-parent'] = $postarray['uri'];
                        $postarray['parent-uri'] = $postarray['uri'];
-                       $postarray['object-type'] = ACTIVITY_OBJ_NOTE;
+                       $postarray['object-type'] = Activity\ObjectType::NOTE;
                }
 
                // Is it me?
@@ -1440,7 +1441,7 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
                $create_user = false;
        } else {
                $postarray['parent-uri'] = $postarray['uri'];
-               $postarray['object-type'] = ACTIVITY_OBJ_NOTE;
+               $postarray['object-type'] = Activity\ObjectType::NOTE;
        }
 
        if ($contactid == 0) {
@@ -1460,7 +1461,7 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
 
        $postarray['contact-id'] = $contactid;
 
-       $postarray['verb'] = ACTIVITY_POST;
+       $postarray['verb'] = Activity::POST;
        $postarray['author-name'] = $postarray['owner-name'];
        $postarray['author-link'] = $postarray['owner-link'];
        $postarray['author-avatar'] = $postarray['owner-avatar'];
@@ -1483,7 +1484,7 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
 
        // When the post contains links then use the correct object type
        if (count($post->entities->urls) > 0) {
-               $postarray['object-type'] = ACTIVITY_OBJ_BOOKMARK;
+               $postarray['object-type'] = Activity\ObjectType::BOOKMARK;
        }
 
        // Search for media links
@@ -1521,9 +1522,9 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
                        Item::insert($retweet);
 
                        // CHange the other post into a reshare activity
-                       $postarray['verb'] = ACTIVITY2_ANNOUNCE;
+                       $postarray['verb'] = Activity::ANNOUNCE;
                        $postarray['gravity'] = GRAVITY_ACTIVITY;
-                       $postarray['object-type'] = ACTIVITY_OBJ_NOTE;
+                       $postarray['object-type'] = Activity\ObjectType::NOTE;
 
                        $postarray['thr-parent'] = $retweet['uri'];
                        $postarray['parent-uri'] = $retweet['uri'];