Skip to content

Commit f17cf9a

Browse files
authored
Mastodon update to version 2.6.0 | optional one-way mode
- An optional one-way mode can be enabled. In this mode, only content from FlatPress is synced to Mastodon. - The plugin will not create, update, or delete any FlatPress content. - Irrelevant options and output are not displayed in the plugin’s admin area when one-way mode is enabled.
2 parents 26a5031 + 7daf13d commit f17cf9a

27 files changed

Lines changed: 2220 additions & 1217 deletions

fp-plugins/mastodon/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,6 @@ After the run, also check:
289289
For technical details you can additionally inspect:
290290

291291
- `fp-content/plugin_mastodon/sync.log`
292-
- `fp-content/plugin_mastodon/sync.guard.json`
293-
- `fp-content/plugin_mastodon/state.json`
294-
- `fp-content/plugin_mastodon/scheduler-state.json`
295-
- `fp-content/plugin_mastodon/rate-limit-windows.json`
296292

297293
## How synchronization works in practice
298294

@@ -367,8 +363,13 @@ If you mainly want a blog-like discussion structure, leaving the option disabled
367363
The plugin stores its working data in:
368364

369365
- `fp-content/plugin_mastodon/state.json`
366+
- `fp-content/plugin_mastodon/state-comments/YY/MM/entry*.json`
370367
- `fp-content/plugin_mastodon/scheduler-state.json`
371368
- `fp-content/plugin_mastodon/sync.log`
369+
- `fp-content/plugin_mastodon/state-write.lock`
370+
- `fp-content/plugin_mastodon/sync.guard.json`
371+
- `fp-content/plugin_mastodon/rate-limit-windows.json`
372+
- `fp-content/plugin_mastodon/sync.log`
372373

373374
Imported Mastodon images are stored under:
374375

fp-plugins/mastodon/developer-docs/00-Mental-Model.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ It maps FlatPress objects to Mastodon objects:
1515
| AudioVideo BBCode | Audio/video media attachments | Requires the FlatPress AudioVideo companion plugin for rendering imported content. |
1616
| FlatPress tags | Hashtag footer / imported `[tag]` BBCode | Requires the FlatPress Tag companion plugin for tag storage/rendering. |
1717
| Local delete | Remote delete or tombstone/recheck | Deletion sync reconciles missing local and remote objects later. |
18+
| One-way import mode | FlatPress-owned source of truth | Optional `disable_remote_import` keeps FlatPress-to-Mastodon export active but blocks Mastodon-created local writes. |
19+
| One-way admin UI | Mode-aware settings/status display | Hides import-only controls, notification hints and local-write counters; preserves hidden import settings on save. |
1820

1921
Media export has one additional compatibility rule that developers must keep in mind: one Mastodon status may carry multiple images, or exactly one audio/video attachment, but not a mixed audio/video/image set. The plugin therefore collects all local media for change detection and diagnostics, then selects one exportable media family per status before upload: images first, otherwise one audio item, otherwise one video item with its poster sent only as an upload thumbnail.
2022

@@ -28,6 +30,7 @@ flowchart LR
2830
Notifications[Mastodon mention notifications]
2931
API[Mastodon API]
3032
Sim[simulate_mastodon_plugin.php regression harness]
33+
AdminUI[Mastodon admin settings and status UI]
3134
3235
FP --> Hooks
3336
Hooks --> State
@@ -36,27 +39,34 @@ flowchart LR
3639
State <--> API
3740
API <--> Notifications
3841
Notifications --> State
42+
OneWay[disable_remote_import option]
3943
API <--> FP
44+
OneWay --> State
45+
OneWay --> AdminUI
46+
OneWay -. blocks Mastodon-to-FlatPress writes .-> FP
47+
AdminUI -. hides import-only controls and counters .-> FP
4048
Sim --> FP
4149
Sim --> State
4250
Sim --> API
4351
```
4452

4553
## The main rule
4654

47-
Notification hints are intentionally a hint layer: they can import replies on old Mastodon threads quickly when `read:notifications` is authorized, while context rotation remains the bounded fallback.
55+
Notification hints are intentionally a hint layer: they can import replies on old Mastodon threads quickly when `read:notifications` is authorized, while context rotation remains the bounded fallback. When `disable_remote_import` is enabled, notification hints and context rotation are skipped as local-write sources; FlatPress still exports local entries and comments to Mastodon.
56+
57+
The admin UI follows the same direction gate. With one-way mode active it hides Mastodon-to-FlatPress import options, notification-scope hints and import-only/local-write counters, but the save handler preserves those hidden import settings so they come back unchanged if bidirectional synchronization is re-enabled. The one-way admin UI hides import-only controls, notification-scope hints and import-only/local-write counters while preserving hidden import settings on save.
4858

4959
Do not reason about a single function in isolation. The important question is usually:
5060

5161
> Which state field is written now, and which later sync path will read it?
5262
53-
Example: a locally deleted mapped comment does not merely remove a local file. It may mark `deletions_pending`, later enter deletion sync, create or respect a comment tombstone, queue descendant rechecks, and prevent a deleted remote reply from being imported again.
63+
Example: a locally deleted mapped comment does not merely remove a local file. It may mark `deletions_pending`, later enter deletion sync, create or respect a comment tombstone, queue descendant rechecks, and prevent a deleted remote reply from being imported again. Conversely, in explicit one-way mode a remotely deleted status must not delete the still-existing FlatPress object; it unlinks the stale remote mapping and queues the local entry or comment for re-export.
5464

5565
## Runtime layers
5666

5767
| Layer | Purpose | Main files/functions |
5868
| ------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
59-
| Configuration | Instance URL, OAuth credentials, feature toggles, cached instance info. | `plugin_mastodon_default_options()`, FlatPress config storage. |
69+
| Configuration | Instance URL, OAuth credentials, feature toggles, cached instance info. | `plugin_mastodon_default_options()`, FlatPress config storage, `disable_remote_import`. |
6070
| Full sync state | Authoritative mapping and dirty/deletion state. | `state.json`, `plugin_mastodon_state_read()`, `plugin_mastodon_state_write()`. |
6171
| Compact scheduler state | Fast request-time status without loading huge mapping arrays. | `scheduler-state.json`, `plugin_mastodon_scheduler_state_read()`. |
6272
| Locks and guards | Prevent concurrent or too frequent sync runs on shared hosting. | `sync.lock`, `sync.guard.json`, `plugin_mastodon_sync_guard_active()`, `plugin_mastodon_sync_guard_mark()`. |
@@ -83,6 +93,7 @@ The simulation executes the real Mastodon plugin code against a local FlatPress-
8393
1. Read the one-page model above and keep `state.json` as the central mental anchor.
8494
2. Locate the affected process ID in `01-Process-Map.md`.
8595
3. Check whether the process is local-to-remote, remote-to-local, deletion-only, or admin-only.
96+
4. One-way mode is a direction gate: it never blocks FlatPress-to-Mastodon export, but it blocks Mastodon-to-FlatPress create, update and delete effects.
8697
4. Read the corresponding state fields in `02-State-Model.md`.
8798
5. Find the implementation functions in `03-Function-Process-Matrix.md`.
8899
6. If Mastodon is contacted, check endpoint version and fallback behavior in `04-API-Compatibility.md`.

0 commit comments

Comments
 (0)