GNU/Weeb Mailing List <[email protected]>
 help / color / mirror / Atom feed
From: Ammar Faizi <[email protected]>
To: GNU/Weeb Mailing List <[email protected]>
Cc: Ammar Faizi <[email protected]>,
	Michael William Jonathan <[email protected]>,
	Nicholas Rosenberg <[email protected]>,
	GNU/Weeb Facebook Team <[email protected]>,
	VNLX Kernel Department <[email protected]>
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	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

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 <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
 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


      parent reply	other threads:[~2023-06-28 19:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-28 19:58 [PATCH fb v1 0/3] A small bug fix for the mbasic changes Ammar Faizi
2023-06-28 19:58 ` [PATCH fb v1 1/3] fb: Fix `getCache()` expiration logic handling Ammar Faizi
2023-06-28 19:58 ` [PATCH fb v1 2/3] fb: .gitignore: Ignore *.patch files Ammar Faizi
2023-06-28 19:58 ` Ammar Faizi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox