Browse Source

Merge pull request #3009 from annando/issue-2999

Issue 2999: Better Mastodon handling
pull/3014/head
Tobias Diekershoff 4 years ago
committed by GitHub
parent
commit
29bc27fa6a
2 changed files with 20 additions and 0 deletions
  1. +4
    -0
      include/items.php
  2. +16
    -0
      include/socgraph.php

+ 4
- 0
include/items.php View File

@ -280,6 +280,10 @@ function add_page_info_to_body($body, $texturl = false, $no_photos = false) {
$URLSearchString = "^\[\]";
// Fix for Mastodon where the mentions are in a different format
$body = preg_replace("/\[url\=([$URLSearchString]*)\]([#!@])(.*?)\[\/url\]/ism",
'$2[url=$1]$3[/url]', $body);
// Adding these spaces is a quick hack due to my problems with regular expressions :)
preg_match("/[^!#@]\[url\]([$URLSearchString]*)\[\/url\]/ism", " ".$body, $matches);


+ 16
- 0
include/socgraph.php View File

@ -391,6 +391,15 @@ function poco_detect_server($profile) {
}
}
// Mastodon
if ($server_url == "") {
$red = preg_replace("=(https?://)(.*)/users/(.*)=ism", "$1$2", $profile);
if ($red != $profile) {
$server_url = $red;
$network = NETWORK_OSTATUS;
}
}
return $server_url;
}
@ -755,6 +764,13 @@ function poco_check_server($server_url, $network = "", $force = false) {
$versionparts = explode("-", $version);
$version = $versionparts[0];
}
if(stristr($line,'Server: Mastodon')) {
$platform = "Mastodon";
$network = NETWORK_OSTATUS;
// Mastodon doesn't reveal version numbers
$version = "";
}
}
}
}


Loading…
Cancel
Save