]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Diaspora.php
Move unfollow protocol to worker task
[friendica.git] / src / Protocol / Diaspora.php
index 5caa6c7a151147d53b296042af66c5872db6f3c3..ad8e2bbef8d28d5c983ba9f2001c831e736e71cd 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -837,8 +837,7 @@ class Diaspora
                // It is deactivated by now, due to side effects. See issue https://github.com/friendica/friendica/pull/4033
                // It is not removed by now. Possibly the code is needed?
                //if (!$is_comment && $contact["rel"] == Contact::FOLLOWER && in_array($importer["page-flags"], array(User::PAGE_FLAGS_FREELOVE))) {
-               //      DBA::update(
-               //              'contact',
+               //      Contact::update(
                //              array('rel' => Contact::FRIEND, 'writable' => true),
                //              array('id' => $contact["id"], 'uid' => $contact["uid"])
                //      );
@@ -858,10 +857,6 @@ class Diaspora
                } elseif (($contact["rel"] == Contact::SHARING) || ($contact["rel"] == Contact::FRIEND)) {
                        // Yes, then it is fine.
                        return true;
-                       // Is it a post to a community?
-               } elseif (($contact["rel"] == Contact::FOLLOWER) && in_array($importer["page-flags"], [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP])) {
-                       // That's good
-                       return true;
                        // Is the message a global user or a comment?
                } elseif (($importer["uid"] == 0) || $is_comment) {
                        // Messages for the global users and comments are always accepted
@@ -2127,8 +2122,7 @@ class Diaspora
        private static function receiveRequestMakeFriend(array $importer, array $contact)
        {
                if ($contact["rel"] == Contact::SHARING) {
-                       DBA::update(
-                               'contact',
+                       Contact::update(
                                ['rel' => Contact::FRIEND, 'writable' => true],
                                ['id' => $contact["id"], 'uid' => $importer["uid"]]
                        );
@@ -2712,6 +2706,9 @@ class Diaspora
 
                        $datarray["object-type"] = Activity\ObjectType::IMAGE;
                        $datarray["post-type"] = Item::PT_IMAGE;
+               } elseif ($data->poll) {
+                       $datarray["object-type"] = Activity\ObjectType::NOTE;
+                       $datarray["post-type"] = Item::PT_POLL;
                } else {
                        $datarray["object-type"] = Activity\ObjectType::NOTE;
                        $datarray["post-type"] = Item::PT_NOTE;
@@ -3470,9 +3467,8 @@ class Diaspora
 
        private static function prependParentAuthorMention($body, $profile_url)
        {
-               $profile = Contact::getByURL($profile_url, false, ['addr', 'name', 'contact-type']);
+               $profile = Contact::getByURL($profile_url, false, ['addr', 'name']);
                if (!empty($profile['addr'])
-                       && $profile['contact-type'] != Contact::TYPE_COMMUNITY
                        && !strstr($body, $profile['addr'])
                        && !strstr($body, $profile_url)
                ) {
@@ -4100,6 +4096,9 @@ class Diaspora
                        $item['private'] = Item::PUBLIC;
                }
 
+               // Don't trigger the addons
+               $item['api_source'] = false;
+
                return Item::insert($item, true);
        }
 }