Repository navigation
Mark posts deleted on the network, and send webhooks when they go or come back - #464
Conversation
Graph answers code 100, subcode 33 when a post was deleted on Instagram or Facebook after publishing, but the Meta error mapping filed it as a generic malformed read, so the publication stayed available and the post card kept showing it as published with a link to a post that no longer exists. The Instagram and Facebook metric collectors now read the post itself when a metrics read fails as malformed. If Graph says the post does not exist while the account's own node still reads with the same token, the post is gone and the publication is marked deleted. The same subcode also means "missing permission", so a token that cannot read the account is never treated as a deletion. Threads is unchanged. A published post whose publication is deleted gets a Deleted badge, a note, Delete and Repost buttons on its card, and may be deleted in TryPost. Refs trypostit#228
|
Thank you @mrbeandev i will check it! |
…ta-posts # Conflicts: # tests/Feature/Analytics/Collectors/PublicationMetricsCollectorsTest.php # tests/Feature/Analytics/PublicationMetricsJobsTest.php
…hreads - Add PublishStatus::Deleted. When the metrics read finds a published post gone (YouTube, or Facebook, Instagram and Threads), the post moves to publish_status deleted (status stays published) and can be deleted in TryPost. A discovery that lists it again restores it. - Move the Meta deletion check into AbstractMetaPublicationMetricsCollector for all three networks. Instagram Login and Threads read `me`; Instagram through Facebook reads the Instagram account, not the Page; Facebook reads the Page. A story older than a day is never reported as deleted. - Stop loading the analytics publication on every card (it sent the whole row to the browser); the deletion rule reads publish_status only. - Hide the network link on the card, the card menu and the details dialog. Drop the duplicate Delete and Repost buttons: the card menu already has Delete and Duplicate. Move the strings to posts.publish.deleted_on_network. - Tests: config URLs in fakes, no fixed dates, Threads and Instagram Login cases, web/API/MCP deletion parity, sent tab props, a browser test of the card, and the badge's single-line budget.
- Only a deletion the collector confirms moves the post: YouTube, or Meta through AnalyticsCollectionException::deletedOnNetwork(). A bare 404 or 410 from other networks only marks the analytics publication, as before. - Meta checks the account's posts edge (published_posts, media, threads), the one discovery reads, instead of the public account node. Stories are never checked, since they expire on their own. - Restoring a post no longer reruns the "just published" side effects. - A post still publishing can't be deleted; a deleted post finalizes as published; the posting goal, lifecycle and PostHog activity keep counting it (Post::scopeWentOut()). - Front end: isDeletedOnNetwork() and postCardPermalink() in usePostCardActions guard the card, menu, details dialog and share/copy; the details dialog shows the Deleted badge; the repurpose list labels the state instead of showing a raw key; the badge is subtle and the hint skips Delete for members who can't delete. - Translations follow each locale's menu words (fr, el, es, nl, uk). - Tests for every guard, each checked to fail without it. - Remove the outdated DEPLOYMENT.md (trypostit#454).
The note under the post moves into a popover on the Deleted badge, like the failure popover. The details dialog shows Deleted in place of Published, so a post shows one status.
Post::isDeletedOnNetwork() replaces PostStatusRules::deletedOnNetwork() and the check in ReadPublicationAnalytics. The popover drops the account line: the card already shows which channel it is.
The title says where the post was deleted; the text says what that changes (no link, no insights) instead of repeating it.
- The details dialog's channel rail shows a deleted sibling as deleted. - YouTube reads its statistics cache once, so an entry expiring between two reads can no longer look like a deleted video. - Meta checks whether a post was deleted only after a read answered "object does not exist", saving a Graph request on live posts whose metrics are refused for another reason. - The metrics job marks a publication and its post deleted under the row lock, and not when a sync saw the post while it was being checked. - PublishStatus::wentOut() is the one definition of "published or deleted", used by the scope and by FinalizePostPublication. - PostDeletedOnNetworkBadge is shared by the popover and the details dialog; RepurposeItemList uses transform(); Italian uses "insight". - post.md and AGENTS.md describe the final rules.
|
I ran the manual test list against One thing to know first: the job only re-reads a publication that has no snapshot for that day ( Results
The Facebook Page post is not detectedFor a deleted Page post (
So for Page posts, Graph answers code 10 both when the post is missing and when the permission is. The account has Checklist
The menu on a deleted post shows Duplicate Post, Post Details and Delete Post; Share and Copy link are gone. ScreenshotsCard and the badge's popover: Post menu and details dialog: Duplicate: At 390px: |
- YouTube uses the statistics it just fetched, so a cache that drops the entry can no longer make a live video look deleted. - Facebook still checks a deleted post on a Page that never granted insights. - PublishStatus::wentOut() uses match and wentOutCases() a collection; the job compares the stored last_seen_at strictly. - The details dialog computes the rail statuses once and tags the icon. - Russian badge agrees with the post's gender. - Tests: the metrics reason on the API and MCP, the lifecycle and PostHog activity counting a deleted post, YouTube without a cache, Facebook without insights, and the browser test asserts the live link and the closed popover.
- YouTube caches only the statistics it found, so a video missing from another video's batch is read again before it is reported deleted. - One recordRefusal() keeps the refusals and the "object does not exist" flag together for every Meta collector. - The details dialog types its rail statuses instead of casting. - The PostHog and lifecycle test lives with the PostHog activity tests; the parity test builds its posts with count(). - AGENTS.md names every read that stays on live posts only.
Each confirms a deletion from the metrics read it already makes, with an account-level read (the list its discovery reads) proving the token still works: - X: the documented resource-not-found problem for the post, in a 200's errors or a 404's body, with no extra request. - Bluesky: getPosts leaves the post out and its repository answers RecordNotFound while listRecords still reads. - Mastodon: a 404 on an owner read, while the account's statuses still read. - Pinterest: a 404 on the Pin analytics and on the Pin, while the Pins list still reads. TikTok cannot tell a deleted video from a private one, and LinkedIn, Google Business, Telegram and Discord have no read after publishing (trypostit#481).
- A deletion check that fails only for now (rate limit, server error) is rethrown, so the job retries instead of settling the publication as gone without a confirmation (Mastodon and Pinterest lost the detection for good). - readsMissing() and stillReads() on AbstractPublicationMetricsCollector are the one confirmation flow for Meta, Bluesky, Mastodon and Pinterest. - X flags the 404 in successfulResponse() and decides once in collect(); the problem must name this post (resource_id required, also in a 404). - Bluesky only handles RecordNotFound and leaves the rest to the parent; SocialAccount::blueskyService() replaces two copies of the PDS lookup. - YouTube caches the batch in a plain loop. - AGENTS.md says which networks need an account read and renders correctly. - Tests: transient checks retried, X thread root and edge problems, Bluesky read once when present and on a self-hosted PDS, Mastodon 410 / 500 / 403 and the exact authenticated list read, Pinterest Pin refused and the exact list read, and the job moving the post for X, Bluesky, Mastodon and Pinterest.
- A Facebook Page without insights keeps its permission refusal when the deletion is not confirmed, instead of turning malformed. - readUnlessDeleted() is the one "read, or report the post deleted" flow for Meta, X, Mastodon and Pinterest; the confirmation helpers are named confirmsDeletion(). - PostFactory::deletedOnNetwork() replaces the repeated published state. - AGENTS.md: 404 or 410 for Mastodon and Pinterest, and the shared helpers. - Tests: a temporary failure is retried on every confirming read (Meta post and posts reads, Pinterest Pin, Bluesky record), Meta only checks after a malformed read and forgets refusals between posts, Bluesky on a fixed self-hosted PDS, a publication removed during the check, the copy link and the live rail label, a publishing post never shown as deleted, and the repurpose Google review label; test helpers deduplicated and the dynamic factory call replaced by a dataset of closures.
|
Thanks a lot for testing this on real accounts, that report is really useful, especially the code 10 answer for deleted Page posts. We'll handle it. I'm testing on my side too and widening the PR: it now covers every network where a deleted post can be detected (X, Bluesky, Mastodon and Pinterest on top of Meta and YouTube), with the rest tracked in #481. It should be ready between today and tomorrow. |
Adds the post.deleted_on_network and post.restored webhook events, guards a deletion against a discovery that saw the post meanwhile (seen_generation), confirms a Facebook video refused for permission by reading the video instead of probing on every read, and writes the network presence transitions in a transaction so their webhook never reads the post without its timestamps.
…porting its config
Every URL in the config goes through one $url closure that removes a trailing slash, so readers append their path to (string) config(...) and no longer trim it (17 reads in app/, 41 in tests). Closes trypostit#484
…pdated The $url closure guarantees a string without a trailing slash, so readers drop the (string) casts on those keys and the account server accessors no longer trim. PostObserver::updated returns early when publish_status did not change and leaves the deleted-origin check to EventType::fromPublishStatus. The webhook dialog browser test counts the events from EventType instead of a fixed six.
One enum method returns the Graph API of Facebook, Instagram (both connections) and Threads, replacing instagramGraphBaseUrl and the abstract graphBaseUrl/baseUrl hooks of the metrics collectors and the carousel resolvers. The Instagram and Threads resolvers were the same class with a different base URL, so they become one MetaCarouselResolver.
data_get() only uses its default when the key is missing, so an account with "service": null or "instance": null made the accessors return null and throw; the publishers' earlier ?? covered it. Also names the network in the deleted-on-network message from Platform::label(), and locks a post's publications by id only.
The read queued when a discovery restores a post ran as a regular read, so a post past its metrics window was skipped and a stale discovery could leave it published for good. It now runs as a baseline read like the daily dispatch and the page queue do, and refreshes a read already done today. The Bluesky deletion test reads the account's stored PDS instead of a literal host.
BlueskyLexicon::xrpc() joins a server and a method, and TelegramApi::botUrl() builds the bot link, so call sites no longer concatenate them by hand.
The /api/v1 prefix lives in one place instead of every call site.
I will release it today. |
Graph answers a deleted Page post's own node with trypostit#10, which also means a missing permission, so the deletion was never confirmed. Its insights edge answers 100/33 (checked against a real deleted post).
Insights list deleted publications, but their details answered 404 when no TryPost post was linked. Web, API and MCP now return them with a null permalink, and the dialog shows the deleted-on-network badge.
The four reasons were string literals across ReadPublicationAnalytics; the enum holds them, and the front end types the union.
A 200 with the resource-not-found problem now goes through readUnlessDeleted like a 404, so the lookup no longer carries its errors back to collect().
…place isDeletedOnNetwork() and postPermalink() are pure helpers, so they live in lib/postPublication.ts instead of the card actions composable. getPostCardStatusConfig() gives the status a post shows, deleted on the network included, which the details rail and the deleted badge now use.
X answers a deleted post with a 200 whose errors name it, single and batch lookups alike (checked against a real deleted post). The lookups check it where the post id is known, so the collector keeps no post id state, needs no successfulResponse override and no readUnlessDeleted wrapper.
The X collector reads the problem type through App\Enums\X\ProblemType and keeps the rule for a deleted post in namesDeletedPost().
fromApiResponse() and isConfirmedDeadToken() match the enum cases instead of basename() and string literals; an unknown type keeps its full type URI as the platform error code.






Refs #228. Closes #454. Closes #484. Thanks to @mrbeandev for finding this and testing it on a real account; this PR builds on that work.
The problem
When a post TryPost published is deleted on the network, TryPost keeps showing it as published, with a "View post" link to a page that no longer exists, and the post cannot be deleted in TryPost (published posts are protected).
The change
Detection, on every network that reads a post again after publishing. The analytics metrics read is the only time TryPost reads a published post again, so detection rides on it: no new job, and an extra request only once a read already failed. A post is marked deleted only when the collector confirms it (
AnalyticsCollectionException::deletedOnNetwork()): the network's documented "does not exist" answer for the post, and, where that answer could also mean lost access, an account-level read with the same token (the list its discovery already reads) still works, so an expired token or a lost permission is never taken for a deletion. A confirming read that fails only for now (rate limit, server error) is rethrown, so the job retries instead of settling without a confirmation./{account}/published_posts,/mediaor/threadsstill reads. A Facebook video or reel read without insights is checked by reading the video, but only once its reads were refused, never on a Page that did not grantpages_read_engagement. Stories are never checked: they expire on their own.videos.list(owner token) no longer returns the video, read by its own request, never from another video's cached batch.resource-not-foundproblem naming the post (resource_typetweet, itsresource_id), in a 200'serrorsor a 404's body, also on the thread lookup with reply polls. No extra request (X bills each one).getPostsleaves the post out, and its repository (the account's PDS, self-hosted included) answersRecordNotFoundwhilelistRecordsstill reads (the AppView also hides moderated posts).readscope; without it a 404 also means private), while the account's statuses still read.Any other 404 or 410 keeps marking only the analytics publication, as before.
Not covered: TikTok's API cannot tell a deleted video from a private one (and TikTok has no delete endpoint, so a wrong "deleted" could not be undone). LinkedIn, Google Business, Telegram and Discord have no read after publishing; #481 specs the networks that can be covered with a new periodic read and the ones that cannot.
Where it is stored. A new
PublishStatus::Deleted(publish_status = deleted), the network side of the post;statusstayspublished. No new column.CollectPublicationMetricswrites it withPost::markPublicationDeleted()under the publication's row lock, unless a sync saw the post since the second the read started (last_seen_atat or after it; a sync earlier in that same second only delays the deletion to the next read). A sync that lists the post again restores it (markPublicationRestored()), without rerunning the "just published" side effects, and queues a fresh metrics read. A discovery reads the publication's post only when the publication was marked deleted, so a normal sync costs no extra query.A post deleted on the network (
Post::isDeletedOnNetwork()):PublishStatus::wentOut(),Post::scopeWentOut()), while live-only reads (Instagram grid, analytics sync, the importer, TikTok ids) keepscopePublicationPublished();publish_status: deletedin API, MCP and webhook payloads, and its metrics answerreason: deleted_on_network.Webhooks. Two new events,
post.deleted_on_networkandpost.restored(EventType::fromPublishStatus()), listed in the webhook settings, the MCP tool and all 16 locales. A post imported from the network sends neither, like it never sentpost.createdorpost.published(ImportExternalPosts). Both transitions also broadcastpost.platform.status.updated, so an open schedule reloads, imported posts included. The transition is written in a transaction, so the webhook never reads the post whilewritePublication()has its timestamps off.UI. The card shows a Deleted badge; clicking it opens a popover ("Deleted on Instagram" / "It was removed after it was published, so its link and insights are no longer available."), like the failure popover. The network link is gone from the card, the menu (Share / Copy link) and the details dialog, whose header and channel rail show Deleted instead of Published. The calendar chip shows a Deleted mark (
calendar.post_status.deleted) and the repurpose activity list labels it too. Insights keep the post's historical numbers and drop its network link in the channel table, the report's top posts and the export (PublicationAvailability::visiblePermalink()). Strings in all 16 locales.Cleanups along the way.
config/trypost.phpgoes through one$url(...)closure that drops a trailing slash, so readers append their path to(string) config(...)and no longer trim it (17 reads inapp/, 41 in tests). Closes Normalize third-party URLs once in config/trypost.php instead of trimming them at every read #484.SocialAccount::bluesky_serviceandmastodon_instance(the account's stored server, else the config default), replacing the copies in the publishers, the connection verifier, the collectors and the rate limits.DEPLOYMENT.md(Remove DEPLOYMENT.md from the repo root #454) andMEDIA_INTEGRATIONS_SETUP.md.Tests
not-authorized-for-resource, another post's or a non-tweet problem, or one withoutresource_id, for a Bluesky record the AppView hides or a deactivated repository, for a Mastodon read without the owner token, for a Pinterest Pin that still reads or is refused, and for YouTube with a cache that keeps nothing or a stale batch. A Bluesky post that is present is read once, also on a self-hosted PDS; the exact account reads (and Mastodon's token) are asserted; a confirming read that fails only for now is retried on every network; Meta only checks after a malformed read and forgets refusals between posts; a Facebook reel without insights is checked by reading the video once, and never on a Page that did not grant reading it.post.published; an imported post sends no webhook but still refreshes;EventType::fromPublishStatus()maps every transition.vue-tscare clean; the full suite passes on PostgreSQL (11,033 tests) and the analytics and post deletion tests on MySQL.Manual test
Plan: reset the database, create a new account, connect every network and check the analytics pull real data from scratch; then publish from TryPost, delete the post on the network and run the metrics job for that publication (
CollectPublicationMetrics). Expect the Deleted badge and popover, no "View post", and Delete in the menu.read)post.deleted_on_network.GET /posts/{id}showspublish_status: deleted, metrics showreason: deleted_on_network, and deleting it works.After deploy
YouTube publications the metrics read already marked deleted before this PR keep their post as published. To see how many there are (read only):