Repository navigation
Accept GIFs on LinkedIn, add GIPHY to the composer, and settle media imports over the socket - #514
Merged
paulocastellano merged 21 commits intoNov 19, 2026
Conversation
The LinkedIn Images API accepts JPG, GIF and PNG (GIF up to 250 frames), and AbstractLinkedInPublisher already uploads GIFs untouched so the animation survives. ContentType::acceptsGif() left LinkedIn out, so scheduling or publishing a LinkedIn post with a GIF failed validation.
Sorvereign
force-pushed
the
feat/linkedin-accepts-gif
branch
from
November 18, 2026 15:20
2ba083d to
f0e0047
Compare
Contributor
|
Thank you @Sorvereign i will review it soon. |
- ContentTypeTest: the pre-centralization snapshot expected linkedin_post.accepts_gif false. - Rule: a GIF over the 5 MB image cap is refused for its size, not for being a GIF; a GIF goes next to other images but never next to a video, on LinkedIn and LinkedIn Page. - API: scheduling a LinkedIn or LinkedIn Page post with a GIF is accepted. - Publisher: the GIF bytes are uploaded untouched (MediaOptimizer never runs), alone and in a multi-image post next to a re-encoded JPEG.
GIFs come from GIPHY in the composer (post and thread replies) and in the idea editor, the same way Unsplash photos do: - GIPHY_ENABLED turns it on or off and GIPHY_API_KEY holds the key; the API, website, download hosts, rating (g by default) and the per-user rate limit can be overridden (.env.example and the Docker example). - GiphyService searches and lists trending GIFs (each page cached), and imports the downsized_medium rendition, which GIPHY keeps under 5 MB. - GiphyController serves search, trending and the import; StoreGiphyMediaRequest only takes files from *.giphy.com and pages on giphy.com, and refuses while GIPHY is off or has no key. - GiphyDialog.vue with "Powered by GIPHY", the official mark from @thesvg/vue in the media menu, and copy in the 16 locales. - The composer's library dialogs (Unsplash and GIPHY) share one target, so a pick lands on the card or the thread reply being edited. - Tests: service and controller (paging, cache, outage, import, hosts, off or keyless, rate limit), menu and source config, and browser flows (pick, paging and search, outage, thread reply, idea editor).
added 7 commits
November 18, 2026 17:03
The logo next to the dialog's title credits GIPHY, so the Powered by GIPHY footer and its copy go. Read the search input through the validated data, name the API timeout, check the GIF page link against the GIPHY website host and simplify the tests' fakes.
GIPHY is an external service nobody hosts themselves, so only the switch, the API key and the rate limit are read from the environment.
This was referenced Nov 18, 2026
added 2 commits
November 18, 2026 18:09
…led over the socket GIPHY, Unsplash and the link preview image no longer download inside the web request, which PHP, Cloudflare and nginx cap well below what a slow download may need: they start a queued ImportRemoteMedia like Google Drive, Google Photos and Canva, limited to images. Unsplash's download tracking runs once the photo landed. Every import now tells the workspace channel when it settles (MediaImportSettled, only its id), and the composer reads its status then, plus once when the tile appears, instead of polling every 1.5 seconds. window.Echo lets browser tests play that broadcast.
…il its image lands An event sent while the socket was down never arrives, so every import still waiting reads its status again once the connection is back. The link preview import shows the site's host instead of the whole URL and keeps its button busy until the image landed, so a second click cannot import it twice.
added 8 commits
November 18, 2026 18:36
The import's types were optional, with null standing for every type, so a new source that forgot them could import anything. StartMediaImport and ImportRemoteMedia now require them, and every arm of StoreMediaImportRequest declares its own: images for GIPHY and Unsplash, every type for Google Drive and Google Photos.
A refused import (422) toasted the generic failure: useHttp keeps the validation errors in its errors, which is now read first. The composer's import code reads top to bottom (no ?? fallbacks), the request builds GIPHY and Unsplash files through the validated input helpers, the Photos session maps through a collection, and the tests use a GIF fixture, datasets and exact messages. New browser tests cover a refused import and an import that settled while the socket was down.
… of our own Echo's Vue package never puts Echo on window, and the app had no reason to: pusher-js already exposes window.Pusher and keeps every client it creates in Pusher.instances, so the browser test helpers reach the connection Echo listens on there.
Two clicks landing before the button turned busy each started an import, so the card's image was added twice.
Google's picker cuts the popup off from the composer (its opener policy), so popup.closed read true seconds after the picker opened, the composer took it for a closed window and deleted the session, and Google then refused the user's Done. The composer now waits for Google to report the pick, or for the session to time out.
obelix58143
pushed a commit
to obelix58143/trypost
that referenced
this pull request
Nov 20, 2026
Since trypostit#514 every import arm names the media types its pick may be, and the WebDAV arm had none, so importing from the share failed with a 500. The browser only lists images and videos, so those are the two types: a document on the share is refused even when its path is posted by hand (new test). Also puts the blank line back between the WebDAV block and the host overrides in both env examples. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three changes, all around getting media into a post:
Closes #516 and #517.
LinkedIn and GIF
AbstractLinkedInPublisheralready skips re-encoding for GIFs so the animation survives.ContentType::acceptsGif()leftLinkedInPostandLinkedInPagePostout, so the rule blocked posts the publisher could send.We run this change on a self-hosted instance, where LinkedIn GIF posts now pass validation.
Changes
ContentType::acceptsGif()returns true forLinkedInPostandLinkedInPagePost. The editor readsaccepts_giffrom the same rules, so no frontend change is needed.ContentTypeTest: LinkedIn and LinkedIn Page accept GIF.ContentTypeCompatibleWithMediaTest: new test, a 2 MB GIF passes on both LinkedIn types. LinkedIn is removed from the "gif is rejected" loop. The "kind violation reported alone" test used LinkedIn as its example of a network that rejects GIF; it now uses a Facebook post, so it still checks the same thing.PostApiPlatformMetaTest: the "rejects publishing a post with a GIF" test now uses Facebook instead of LinkedIn, for the same reason.The 5 MB LinkedIn image cap still applies to GIFs. The 250-frame limit is not checked here, same as the other networks that accept GIF.
Test plan
php artisan test tests/Unit/Enums/ContentTypeTest.php tests/Unit/Rules/ContentTypeCompatibleWithMediaTest.php tests/Feature/Api/PostApiPlatformMetaTest.php(run by the maintainers, with the full backend suite and the affected browser tests)acceptsGif()deployed on a self-hosted instance;ContentType::LinkedInPost->acceptsGif()returns true and GIF drafts validate.Added by the maintainers
Tests for every LinkedIn GIF case
ContentTypeTestexpectedlinkedin_post.accepts_giffalse (the one failing test).MediaOptimizernever runs), alone and in a multi-image post next to a re-encoded JPEG.GIPHY in the composer
So a GIF can be picked without leaving TryPost, GIPHY joins the composer's media sources, the same way Unsplash does:
GIPHY_ENABLEDandGIPHY_API_KEYin.env.exampleand the Docker example. The API, website, download hosts, thegrating and the per-user rate limit are fixed inconfig/trypost.php.GiphyService(search and trending, cached per page; an empty page ends the list, since GIPHY'stotal_countruns ahead of what a search can reach) andGiphyController(search and trending). A picked GIF (thedownsized_mediumrendition, kept under 5 MB by GIPHY) is imported through the media import queue (see below): the GIPHY arm ofStoreMediaImportRequestonly takes files from*.giphy.comand pages ongiphy.com, and images only.GiphyDialog.vue, with the GIPHY mark (@thesvg/vue/giphy) before its title as the attribution, the same mark in the media menu, copy in the 16 locales.Media imports through the queue, settled over the socket
GIPHY, Unsplash and "Replace link preview with media" used to download inside the web request, capped by PHP (60 s in production), Cloudflare (100 s) and nginx, so a slow download ended in a 500. They now go through the queue Google Drive, Google Photos and Canva already use:
StoreMediaImportRequestgains a GIPHY and an Unsplash arm (the rules of the removedStoreGiphyMediaRequestandStoreMediaFromUrlRequest), each limited to images. Every arm now declares the types it may be (importTypes(), required byStartMediaImportandImportRemoteMedia: images for GIPHY and Unsplash, every type for Google Drive and Google Photos), so a new source cannot import any type by forgetting them.LinkPreviewMediaControllerreads the card's image (cached, the composer already fetched it) and queues it the same way, images only; it answers 202 with the import id. The card's button stays busy until the image landed, and the pending tile shows the link's site.POST media/from-url,POST media/giphyand the in-request timeouts.Every import now settles over the socket instead of polling:
MediaImportStatus::complete()/fail()dispatchMediaImportSettledonprivate-workspace.{id}(media.import.settled, only theimport_id, since every member hears that channel; the result is still read fromGET media/imports/{id}, which answers the import's starter alone).useMediaImportlistens withuseWorkspaceEcho, reads the status once when the tile appears (the job may have finished first), again when its event arrives, and again for every waiting import when the socket connects anew (an event sent while it was down never arrives). The 1.5-second polling loop is gone. This covers Google Drive, Google Photos, Canva, GIPHY, Unsplash and the link preview.useHttp'serrors), where it always toasted the generic failure before.broadcastToPage()) and a reconnection (reconnectPageSocket()) intests/Pest.phpthrough the Pusher client Echo connects with, which pusher-js already exposes (window.Pusher.instances); the app code is untouched. Laravel's docs only cover the server side (thenulldriver andEvent::fake), which the feature tests use.Google Photos picker refused "Done" (found while testing)
Google's picker cuts the popup off from the composer (its
Cross-Origin-Opener-Policy), sopopup.closedreadtruea few seconds after the picker opened. The composer took it for a closed window and deleted the session, and Google then answered the user's "Done" with "couldn't add photos".googlePhotos.tsno longer readspopup.closed: it waits for Google to report the pick, or discards the session when Google's timeout passes. Browser tests: a window reading closed while the user picks keeps the session and lands the photos (fails without the fix); a session nobody picks in time is discarded.Reverb has to be running for an import to finish in the composer (Docker already starts it in
supervisord, and connecting Telegram already depended on it).Manual tests
Before starting: Horizon and Reverb running,
GIPHY_API_KEYandUNSPLASH_ACCESS_KEYset, a LinkedIn profile, a LinkedIn page, an X or Bluesky account and a Facebook or Instagram account connected. Keep DevTools' Network tab open for the import checks.LinkedIn and GIF
GIPHY
grating, its strictest, and every result comes ratedg(which GIPHY decides; a few suggestive GIFs carry it too).GIPHY_API_KEY, the dialog shows the error message instead of an empty result.GIPHY_ENABLED=false, or without a key, GIPHY is gone from the media menu..env.exampleanddocker/.env.docker.examplelist onlyGIPHY_ENABLEDandGIPHY_API_KEY.Unsplash
MediaUploadControllerTest).UNSPLASH_ACCESS_KEY, Unsplash is gone from the media menu.Replace link preview with media
Imports through the queue and the socket
GET media/imports/{id}repeating every 1.5 seconds (one read when the tile appears and one when the import settles).media.import.settledonprivate-workspace.{id}carrying only theimport_id, never the file or its URL.MediaUploadControllerTestandGiphyControllerTest).