Compare commits

..

No commits in common. "7825565b3dee831f319589f994f8bc94ac870032" and "faef38bec7590aa2409d96c79e7737923640741e" have entirely different histories.

7 changed files with 27 additions and 46 deletions

2
.gitattributes vendored
View file

@ -1,6 +1,6 @@
.gitattributes export-ignore .gitattributes export-ignore
LICENSE export-ignore LICENSE export-ignore
help*.md export-ignore help-gotoso*.md export-ignore
readme*.md export-ignore readme*.md export-ignore
# Auto detect text files and perform LF normalization # Auto detect text files and perform LF normalization
* text=auto * text=auto

View file

@ -1,14 +1,14 @@
# Datenstrom Yellow extension settings # Datenstrom Yellow extension settings
Extension: Mastodonapi Extension: Mastodonapi
Version: 0.9.8 Version: 0.9.7
Description: Import your toots into your blog. Description: Import your toots into your blog.
Developer: Simon Rohr Developer: Simon Rohr
Tag: feature Tag: feature
DownloadUrl: https://codeberg.org/simonpipe/yellow-mastodonapi/archive/main.zip DownloadUrl: https://codeberg.org/simonpipe/yellow-mastodonapi/archive/main.zip
DocumentationUrl: https://codeberg.org/simonpipe/yellow-mastodonapi DocumentationUrl: https://codeberg.org/simonpipe/yellow-mastodonapi
DocumentationLanguage: en, de DocumentationLanguage: en, de
Published: 2026-05-27 14:20:00 Published: 2026-05-27 08:35:00
Status: experimental Status: experimental
system/workers/mastodonapi.php: mastodonapi.php, create, update system/workers/mastodonapi.php: mastodonapi.php, create, update
system/workers/mastodonapi.status: mastodonapi.status, create, update, careful system/workers/mastodonapi.status: mastodonapi.status, create, update, careful

View file

@ -6,7 +6,7 @@
1. Ersetze in diesem Link die Platzhalter und öffne ihn im Browser: 1. Ersetze in diesem Link die Platzhalter und öffne ihn im Browser:
``` ```
https://DEINE_INSTANZ_URL/oauth/x-snac-get-token https://snac.thepipes.ch/oauth/x-snac-get-token
``` ```
→ Anmelden, bestätigen und den **Code** kopieren. → Anmelden, bestätigen und den **Code** kopieren.

View file

@ -6,7 +6,7 @@
1. Adjust the following link and paste it into your browser: 1. Adjust the following link and paste it into your browser:
``` ```
https://YOUR_INSTANCE_URL/oauth/x-snac-get-token https://snac.thepipes.ch/oauth/x-snac-get-token
``` ```
→ Log in, authorize, and copy the **code**. → Log in, authorize, and copy the **code**.

View file

@ -2,7 +2,7 @@
// Mastodonapi extension, https://codeberg.org/simonpipe/yellow-mastodonapi // Mastodonapi extension, https://codeberg.org/simonpipe/yellow-mastodonapi
class YellowMastodonapi { class YellowMastodonapi {
const VERSION = "0.9.8"; const VERSION = "0.9.7";
public $yellow; // access to API public $yellow; // access to API
// Initialize extension // Initialize extension
@ -103,46 +103,30 @@ class YellowMastodonapi {
echo "DEBUG: " . count($posts) . " Posts von API empfangen.\n"; echo "DEBUG: " . count($posts) . " Posts von API empfangen.\n";
$postsCreated = 0; $postsCreated = 0;
foreach ( $posts as $index => $post ) { foreach ( $posts as $post ) {
// Snac-Verschachtelung auflösen: Wenn ein echtes 'reblog'-Objekt von jemand anderem drinsteckt // FIX: Reblog-Erkennung robuster für Snac
if ( !empty($post["reblog"]) && is_array($post["reblog"]) ) { if ( !empty($post["reblog"]) || (isset($post["reblogged"]) && $post["reblogged"]===true) ) {
// Nur überspringen, wenn es wirklich der Post eines ANDEREN Nutzers ist, den du geteilt hast continue;
if ( !empty($post["reblog"]["account"]["id"]) && $post["reblog"]["account"]["id"] != $accountId ) { }
echo "DEBUG [$index]: Übersprungen (Echter Reblog eines fremden Beitrags)\n";
continue; // FIX: Snac sendet leere Strings "" statt null bei in_reply_to_id
} if ( !empty($post["in_reply_to_id"]) ) {
// Wenn es dein eigener ist, nutzen wir die inneren Daten continue;
$post = $post["reblog"];
} }
$contentHtml = $post["content"] ?? ""; $contentHtml = $post["content"] ?? "";
$createdAt = $post["created_at"] ?? ""; $createdAt = $post["created_at"] ?? "";
$shortText = mb_substr(strip_tags($contentHtml), 0, 40) . "...";
// Reblogged-Flag nur werten, wenn es kein Eigen-Boost ist
if ( (isset($post["reblogged"]) && $post["reblogged"]===true) && empty($contentHtml) ) {
echo "DEBUG [$index]: Übersprungen (Leerer Boost): $shortText\n";
continue;
}
// REPLY CHECK (Snac sendet leere Strings oder null)
if ( !empty($post["in_reply_to_id"]) ) {
echo "DEBUG [$index]: Übersprungen (Antwort - Reply-ID: " . $post["in_reply_to_id"] . "): $shortText\n";
continue;
}
// ALTER CHECK
if ( $maxAgeHours > 0 ) { if ( $maxAgeHours > 0 ) {
if ( strtotime($createdAt) < ( time() - ( $maxAgeHours * 3600 ) ) ) { if ( strtotime($createdAt) < ( time() - ( $maxAgeHours * 3600 ) ) ) {
echo "DEBUG [$index]: Übersprungen (Zu alt - Datum: $createdAt): $shortText\n"; echo "DEBUG: Post übersprungen (zu alt): " . mb_substr(strip_tags($contentHtml), 0, 30) . "...\n";
continue; continue;
} }
} }
// HASHTAG CHECK
$tags = array_column($post["tags"] ?? array(), "name"); $tags = array_column($post["tags"] ?? array(), "name");
if ( !empty($hashtag) && !in_array(strtolower($hashtag), array_map("strtolower", $tags)) ) { if ( !empty($hashtag) && !in_array(strtolower($hashtag), array_map("strtolower", $tags)) ) {
echo "DEBUG [$index]: Übersprungen (Hashtag #$hashtag fehlt): $shortText\n"; echo "DEBUG: Post übersprungen (Hashtag #$hashtag fehlt): " . mb_substr(strip_tags($contentHtml), 0, 30) . "...\n";
continue; continue;
} }
@ -151,9 +135,8 @@ class YellowMastodonapi {
$fileName = date("Y-m-d", strtotime($createdAt)) . "-" . $titleSlug . ".md"; $fileName = date("Y-m-d", strtotime($createdAt)) . "-" . $titleSlug . ".md";
$fullPath = $this->yellow->system->get("coreServerDocument") . $targetFolder . $fileName; $fullPath = $this->yellow->system->get("coreServerDocument") . $targetFolder . $fileName;
// EXISTENZ CHECK
if ( file_exists($fullPath) ) { if ( file_exists($fullPath) ) {
echo "DEBUG [$index]: Übersprungen (Datei existiert bereits: $fileName): $shortText\n"; echo "DEBUG: Post übersprungen (Datei existiert bereits: $fileName)\n";
continue; continue;
} }
@ -185,7 +168,7 @@ class YellowMastodonapi {
file_put_contents($fullPath, $markdownContent); file_put_contents($fullPath, $markdownContent);
chmod($fullPath, 0666); chmod($fullPath, 0666);
echo "-> ERSTELLT [$index]: $fileName ($shortText)\n"; echo "-> Erstellt: $fileName\n";
$postsCreated++; $postsCreated++;
} }
return $postsCreated; return $postsCreated;

View file

@ -1,6 +1,6 @@
<p align="right"><a href="https://codeberg.org/simonpipe/yellow-mastodonapi/src/branch/main/readme-de.md">Deutsch</a> &nbsp; <a href="https://codeberg.org/simonpipe/yellow-mastodonapi/src/branch/main/readme.md">English</a></p> <p align="right"><a href="https://codeberg.org/simonpipe/yellow-mastodonapi/src/branch/main/readme-de.md">Deutsch</a> &nbsp; <a href="https://codeberg.org/simonpipe/yellow-mastodonapi/src/branch/main/readme.md">English</a></p>
# Mastodonapi 0.9.8 # Mastodonapi 0.9.7
Importiere deine Toots in deinen Blog. Getestet mit <a href="https://comam.es/what-is-snac">Snac</a>. Importiere deine Toots in deinen Blog. Getestet mit <a href="https://comam.es/what-is-snac">Snac</a>.
@ -30,7 +30,7 @@ Alle Einstellungen befinden sich in `system/extensions/yellow-system.ini`:
*Finde die ID eines Snac oder Mastodon Accounts: Gib "https://DEINE_INSTANZ_URL/api/v1/accounts/lookup?acct=PROFILNAME" in deinen Browser ein.* *Finde die ID eines Snac oder Mastodon Accounts: Gib "https://DEINE_INSTANZ_URL/api/v1/accounts/lookup?acct=PROFILNAME" in deinen Browser ein.*
*Finde die ID eines GoToSocial-Accounts <a href="https://codeberg.org/simonpipe/yellow-mastodonapi/src/branch/main/help-de.md">(siehe hier)</a>* *Finde die ID eines GoToSocial-Accounts <a href="https://codeberg.org/simonpipe/yellow-mastodonapi/src/branch/main/help-de.md">(siehe hier)</a>*
`MastodonapiAccessToken` = optional für einen Mastodon-Account, zwingend für einen GoToSocial-Account <a href="https://codeberg.org/simonpipe/yellow-mastodonapi/src/branch/main/help-de.md">(Wie komme ich zu einem Token?)</a> `MastodonapiAccessToken` = optional für einen Mastodon-Account, zwingend für einen GoToSocial-Account <a href="https://codeberg.org/simonpipe/yellow-mastodonapi/src/branch/main/help-de.md">(siehe hier)</a>
`MastodonapiUpdateInterval` = Zeitintervall zwischen automatischen Updates in Minuten (Standard: 30) `MastodonapiUpdateInterval` = Zeitintervall zwischen automatischen Updates in Minuten (Standard: 30)
`MastodonapiLimit` = Anzahl der Toots, die pro Durchgang abgerufen werden (Standard: 20) `MastodonapiLimit` = Anzahl der Toots, die pro Durchgang abgerufen werden (Standard: 20)
`MastodonapiHashtag` = leer lassen für alle Beiträge; oder mit #hashtag filtern `MastodonapiHashtag` = leer lassen für alle Beiträge; oder mit #hashtag filtern
@ -49,4 +49,3 @@ Die folgenden Status-Werte werden unterstützt:
## Entwickler ## Entwickler
Simon Rohr Simon Rohr
*Fediverse: <a href="https://snac.thepipes.ch/simon">@simon@snac.thepipes.ch</a>*

View file

@ -1,6 +1,6 @@
<p align="right"><a href="https://codeberg.org/simonpipe/yellow-mastodonapi/src/branch/main/readme-de.md">Deutsch</a> &nbsp; <a href="https://codeberg.org/simonpipe/yellow-mastodonapi/src/branch/main/readme.md">English</a></p> <p align="right"><a href="https://codeberg.org/simonpipe/yellow-mastodonapi/src/branch/main/readme-de.md">Deutsch</a> &nbsp; <a href="https://codeberg.org/simonpipe/yellow-mastodonapi/src/branch/main/readme.md">English</a></p>
# Mastodonapi 0.9.8 # Mastodonapi 0.9.7
Import your toots into your blog. Tested with <a href="https://comam.es/what-is-snac">Snac</a>. Import your toots into your blog. Tested with <a href="https://comam.es/what-is-snac">Snac</a>.
@ -30,7 +30,7 @@ All settings are in `system/extensions/yellow-system.ini`:
*Find the ID of a Snac or Mastodon account: Enter "https://YOUR_INSTANCE_URL/api/v1/accounts/lookup?acct=PROFILNAME" in your browser.* *Find the ID of a Snac or Mastodon account: Enter "https://YOUR_INSTANCE_URL/api/v1/accounts/lookup?acct=PROFILNAME" in your browser.*
*Find the ID of a GoToSocial account <a href="https://codeberg.org/simonpipe/yellow-mastodonapi/src/branch/main/help-en.md">(see here)</a>* *Find the ID of a GoToSocial account <a href="https://codeberg.org/simonpipe/yellow-mastodonapi/src/branch/main/help-en.md">(see here)</a>*
`MastodonapiAccessToken` = optional for a Mastodon account, mandatory for a GoToSocial account <a href="https://codeberg.org/simonpipe/yellow-mastodonapi/src/branch/main/help-en.md">(How do I get a token?)</a> `MastodonapiAccessToken` = optional for a Mastodon account, mandatory for a GoToSocial account <a href="https://codeberg.org/simonpipe/yellow-mastodonapi/src/branch/main/help-en.md">(see here)</a>
`MastodonapiUpdateInterval` = time interval between automatic updates in minutes (default: 30) `MastodonapiUpdateInterval` = time interval between automatic updates in minutes (default: 30)
`MastodonapiLimit` = number of Toots retrieved per run (default: 20) `MastodonapiLimit` = number of Toots retrieved per run (default: 20)
`MastodonapiHashtag` = leave blank for all posts; or filter with #hashtag `MastodonapiHashtag` = leave blank for all posts; or filter with #hashtag
@ -49,4 +49,3 @@ The following status values are supported:
## Developer ## Developer
Simon Rohr Simon Rohr
*Fediverse: <a href="https://snac.thepipes.ch/simon">@simon@snac.thepipes.ch</a>*