]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #7153 from annando/ap-mail-delivery
authorHypolite Petovan <hypolite@mrpetovan.com>
Sat, 18 May 2019 15:50:10 +0000 (11:50 -0400)
committerGitHub <noreply@github.com>
Sat, 18 May 2019 15:50:10 +0000 (11:50 -0400)
Fix receiver list for mails

config/dbstructure.config.php
src/Protocol/ActivityPub/Processor.php
src/Protocol/ActivityPub/Receiver.php
src/Protocol/ActivityPub/Transmitter.php

index baca2bec635abe698d7274af6075aa5313f3c69c..57e4378376e08eb72e3f8b7302c5170523761350 100755 (executable)
@@ -41,8 +41,8 @@ return [
        "2fa_recovery_codes" => [
                "comment" => "Two-factor authentication recovery codes",
                "fields" => [
-                       "uid" => ["type" => "int unsigned", "not null" => "1", "comment" => "User ID"],
-                       "code" => ["type" => "varchar(50)", "not null" => "1", "comment" => "Recovery code string"],
+                       "uid" => ["type" => "mediumint unsigned", "not null" => "1", "primary" => "1", "relation" => ["user" => "uid"], "comment" => "User ID"],
+                       "code" => ["type" => "varchar(50)", "not null" => "1", "primary" => "1", "comment" => "Recovery code string"],
                        "generated" => ["type" => "datetime", "not null" => "1", "comment" => "Datetime the code was generated"],
                        "used" => ["type" => "datetime", "comment" => "Datetime the code was used"],
                ],
index b6f3486a2526f73948a573966f21c976b15dab55..045c48a4c1ced304920444f465f559bd6973d65a 100644 (file)
@@ -64,10 +64,9 @@ class Processor
         *
         * @param array   $tags
         * @param boolean $sensitive
-        * @param array   $implicit_mentions List of profile URLs to skip
         * @return string with tags
         */
-       private static function constructTagString(array $tags, $sensitive)
+       private static function constructTagString(array $tags = null, $sensitive = false)
        {
                if (empty($tags)) {
                        return '';
@@ -174,7 +173,7 @@ class Processor
                        $item['object-type'] = ACTIVITY_OBJ_COMMENT;
                }
 
-               if (($activity['id'] != $activity['reply-to-id']) && !Item::exists(['uri' => $activity['reply-to-id']])) {
+               if (empty($activity['directmessage']) && ($activity['id'] != $activity['reply-to-id']) && !Item::exists(['uri' => $activity['reply-to-id']])) {
                        Logger::log('Parent ' . $activity['reply-to-id'] . ' not found. Try to refetch it.');
                        self::fetchMissingActivity($activity['reply-to-id'], $activity);
                }
index 7ae68cd4d1247238fc50a15ef6fa1030ff7d4463..74d939275225c186b2066a6e5ac8612f18efeae1 100644 (file)
@@ -207,7 +207,13 @@ class Receiver
                                return [];
                        }
                        $object_data['object_id'] = $object_id;
-                       $object_data['directmessage'] = JsonLD::fetchElement($activity, 'litepub:directMessage');
+
+                       // Test if it is an answer to a mail
+                       if (DBA::exists('mail', ['uri' => $object_data['reply-to-id']])) {
+                               $object_data['directmessage'] = true;
+                       } else {
+                               $object_data['directmessage'] = JsonLD::fetchElement($activity, 'litepub:directMessage');
+                       }
 
                        // We had been able to retrieve the object data - so we can trust the source
                        $trust_source = true;
@@ -936,11 +942,6 @@ class Receiver
 
                $object_data['receiver'] = self::getReceivers($object, $object_data['actor'], $object_data['tags']);
 
-               // Test if it is an answer to a mail
-               if (DBA::exists('mail', ['uri' => $object_data['reply-to-id']])) {
-                       $object_data['directmessage'] = true;
-               }
-
                // Common object data:
 
                // Unhandled
index 09c56fa6f859dc5fff19dddbe9b084fe58f748f6..7fc5e2df0665ced6a9e0a478ba14e49617940ef4 100644 (file)
@@ -647,6 +647,12 @@ class Transmitter
 
                $reply = DBA::selectFirst('mail', ['uri'], ['parent-uri' => $mail['parent-uri'], 'reply' => false]);
 
+               // Making the post more compatible for Mastodon by:
+               // - Making it a note and not an article (no title)
+               // - Moving the title into the "summary" field that is used as a "content warning"
+               $mail['body'] = '[abstract]' . $mail['title'] . "[/abstract]\n" . $mail['body'];
+               $mail['title'] = '';
+
                $mail['author-link'] = $mail['owner-link'] = $mail['from-url'];
                $mail['allow_cid'] = '<'.$mail['contact-id'].'>';
                $mail['allow_gid'] = '';