From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1687982323; bh=ar43sKLPY8tEXVjqpImZ9B0IROtcJJ2AWN03Wc7ygqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mPDO+j5dTftt9BqMo0htBW8/kl7DvyfwUcwKsRhLGgvP/Ah0dJNzijmcjdYNYBtmE MeOXZ7lKhLwdoI9YTPjUTPoCWvK/XMSmCsjJKsePI6NNzDu39ROgvNu1L/JhNCxtdL yfSSavY0DmR9h9W9m39Z0sHtgqwW8SfSrs/4WlHZzxSVYy7sQM6QxT4XJmEsmWXnvO EoaMIVVSQ9vynNDnY5GV3pddmiCV1L9hApKlnqeT8bi0DdecvV+y5GS/iTyNT+tNLd 8ovSZQXLIo7O7jsO6GoObMcIEmbRdc1txeLyrpVsbCxFDCWtrjMgTbwm5CsGITzGQW sdyMQ7GHwWfsA== Received: from integral2.. (unknown [68.183.184.174]) by gnuweeb.org (Postfix) with ESMTPSA id 84A2F2370D3; Thu, 29 Jun 2023 02:58:41 +0700 (WIB) From: Ammar Faizi To: GNU/Weeb Mailing List Cc: Ammar Faizi , Michael William Jonathan , Nicholas Rosenberg , GNU/Weeb Facebook Team , VNLX Kernel Department Subject: [PATCH fb v1 3/3] fb: Post: Fix the wrong content type detection (photo issue) Date: Thu, 29 Jun 2023 02:58:28 +0700 Message-Id: <20230628195828.1657850-4-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230628195828.1657850-1-ammarfaizi2@gnuweeb.org> References: <20230628195828.1657850-1-ammarfaizi2@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Michael reports that using the recent API, photo contents in the HonkaiStarRail.ID timeline are detected as a "text". Using the current parser, it detects those contents as a text with a link preview (where the preview is the post to the photo). Just visit the photo link if there exists before continue trying to parse it as a photo. Also, make sure we try to parse as a photo first before text. Cc: Michael William Jonathan Signed-off-by: Ammar Faizi --- src/Facebook/Methods/Post.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Facebook/Methods/Post.php b/src/Facebook/Methods/Post.php index 7fe38c5c1b982c72..8c02d0f70e553c14 100644 --- a/src/Facebook/Methods/Post.php +++ b/src/Facebook/Methods/Post.php @@ -281,6 +281,11 @@ trait Post "alt" => NULL, ]; + + if (preg_match("/\/photo.php\?fbid=(\d+)/", $o, $m)) { + $o = $this->http("/photo.php?fbid={$m[1]}", "GET")["out"]; + } + /* * Parse photo URLs. Currently, only one photo is parsed. */ @@ -341,12 +346,12 @@ trait Post */ private function parsePostContent(string $o): array { - $ret = $this->tryParseTextPost($o); + $ret = $this->tryParsePhotoPost($o); if ($ret) { return $ret; } - $ret = $this->tryParsePhotoPost($o); + $ret = $this->tryParseTextPost($o); if ($ret) { return $ret; } -- Ammar Faizi