Skip to content

Accept GIFs on LinkedIn, add GIPHY to the composer, and settle media imports over the socket - #514

Merged
paulocastellano merged 21 commits into
trypostit:mainfrom
Sorvereign:feat/linkedin-accepts-gif
Nov 19, 2026
Merged

paulocastellano merged 21 commits into
trypostit:mainfrom
Sorvereign:feat/linkedin-accepts-gif

Conversation

@Sorvereign

@Sorvereign Sorvereign commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Three changes, all around getting media into a post:

  1. LinkedIn accepts animated GIFs. Posts with a GIF failed validation with "This platform does not accept GIF", although LinkedIn supports them and the publisher already handles them.
  2. GIPHY in the composer, next to Unsplash, so a GIF can be picked without leaving TryPost.
  3. Media imports run on the queue and settle over the socket. GIPHY, Unsplash and "Replace link preview with media" no longer download inside the web request, and every import (Google Drive, Google Photos, Canva included) learns it finished through Reverb instead of polling.

Closes #516 and #517.

LinkedIn and GIF

  • The LinkedIn Images API accepts JPG, GIF and PNG, and GIFs up to 250 frames (Images API docs).
  • AbstractLinkedInPublisher already skips re-encoding for GIFs so the animation survives.
  • Only ContentType::acceptsGif() left LinkedInPost and LinkedInPagePost out, 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 for LinkedInPost and LinkedInPagePost. The editor reads accepts_gif from the same rules, so no frontend change is needed.
  • Tests:
    • 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)
  • Patched acceptsGif() deployed on a self-hosted instance; ContentType::LinkedInPost->acceptsGif() returns true and GIF drafts validate.
  • Publish a LinkedIn post with an animated GIF (picked from GIPHY in the composer) and confirm it plays in the feed.

Added by the maintainers

Tests for every LinkedIn GIF case

  • The editor-limits snapshot in ContentTypeTest expected linkedin_post.accepts_gif false (the one failing test).
  • 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 (profile and page).
  • Scheduling a LinkedIn or LinkedIn Page post with a GIF is accepted through the API.
  • The publisher uploads the GIF bytes untouched (MediaOptimizer never 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_ENABLED and GIPHY_API_KEY in .env.example and the Docker example. The API, website, download hosts, the g rating and the per-user rate limit are fixed in config/trypost.php.
  • GiphyService (search and trending, cached per page; an empty page ends the list, since GIPHY's total_count runs ahead of what a search can reach) and GiphyController (search and trending). A picked GIF (the downsized_medium rendition, kept under 5 MB by GIPHY) is imported through the media import queue (see below): the GIPHY arm of StoreMediaImportRequest only takes files from *.giphy.com and pages on giphy.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.
  • The composer's library dialogs (Unsplash and GIPHY) share one target, so a pick lands on the card or on the thread reply being edited. Also in the idea editor.
  • Tests: service and controller (paging, the empty last page, cache, outage, import, hosts, off or keyless, rate limit), source config and menu, browser flows (pick, paging and search, outage, thread reply, idea editor).
  • Tests: the GIPHY import through the queue, including a video on a GIPHY host refused.

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:

  • StoreMediaImportRequest gains a GIPHY and an Unsplash arm (the rules of the removed StoreGiphyMediaRequest and StoreMediaFromUrlRequest), each limited to images. Every arm now declares the types it may be (importTypes(), required by StartMediaImport and ImportRemoteMedia: images for GIPHY and Unsplash, every type for Google Drive and Google Photos), so a new source cannot import any type by forgetting them. LinkPreviewMediaController reads 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.
  • Unsplash's download tracking (required by its API guidelines) runs from the job once the photo landed, never for a failed import.
  • Removed: POST media/from-url, POST media/giphy and the in-request timeouts.

Every import now settles over the socket instead of polling:

  • MediaImportStatus::complete() / fail() dispatch MediaImportSettled on private-workspace.{id} (media.import.settled, only the import_id, since every member hears that channel; the result is still read from GET media/imports/{id}, which answers the import's starter alone).
  • useMediaImport listens with useWorkspaceEcho, 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.
  • The GIPHY and Unsplash dialogs start the import and close; the composer and the idea editor show the pending tile like the other sources.
  • An import the server refuses (422) now toasts the server's reason (read from useHttp's errors), where it always toasted the generic failure before.
  • Browser tests play a broadcast (broadcastToPage()) and a reconnection (reconnectPageSocket()) in tests/Pest.php through 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 (the null driver and Event::fake), which the feature tests use.
  • Tests: the event on success, failure and a dead job (channel and payload); Unsplash and link preview imports through the queue, refusals (hosts, disabled source, not an image, a video, too large) and tracking only after success; a browser test where the GIF stays loading until the event arrives (it fails without it); browser tests for an import that settled while the socket was down (it lands on reconnection) and for a refused import (the reason is toasted, the dialog stays open); the edit-in-Canva browser test now settles through the event.

Google Photos picker refused "Done" (found while testing)

Google's picker cuts the popup off from the composer (its Cross-Origin-Opener-Policy), so popup.closed read true a 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.ts no longer reads popup.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_KEY and UNSPLASH_ACCESS_KEY set, 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

  • A LinkedIn profile post with a GIF shows no "does not accept GIF" warning and can be scheduled.
  • Published, the GIF plays in the LinkedIn feed.
  • The same on a LinkedIn page post.
  • A GIF next to a JPEG on LinkedIn publishes as a multi-image post, and the GIF still plays.
  • A GIF next to a video on LinkedIn shows the mixed media warning.
  • A GIF over 5 MB on LinkedIn says the image is too large, not that GIFs are refused.
  • Facebook and Instagram still say they do not accept GIF.
  • A GIF picked from GIPHY on an Instagram or Facebook post shows the same warning (GIPHY stays in the menu on purpose).
  • A GIF from GIPHY published on another network that takes GIF (X or Telegram) plays there too.

GIPHY

  • The media menu shows GIPHY with its logo, in light and dark mode.
  • The dialog shows the GIPHY logo before its title and has no "Powered by GIPHY" footer.
  • The Unsplash dialog shows its logo before its title too.
  • Trending GIFs load on open, and scrolling down loads more.
  • Typing searches after a short pause; a search with no results shows the empty message; clearing the search goes back to trending.
  • Scrolling a search result loads its next page too.
  • Searches and trending ask GIPHY for the g rating, its strictest, and every result comes rated g (which GIPHY decides; a few suggestive GIFs carry it too).
  • Searching very fast for a minute (over 30 requests) shows the error message until the minute passes, while another user keeps searching.
  • At phone width the dialog fits the screen, with the grid in two columns.
  • Picking a GIF closes the dialog, the GIF shows loading in the post, then appears.
  • Saved and reopened, the post still has the GIF.
  • Picked from a network card (Customize for each network), the GIF lands on that card only.
  • Picked while a thread reply is edited (X or Bluesky), the GIF lands on that reply, not on the post.
  • Picked in the idea editor, the GIF joins the idea.
  • While the GIF is loading, saving the post waits for it (the save button stays disabled).
  • Removing the loading tile before it finishes leaves no GIF in the post once the import ends.
  • Closing the composer while a GIF is loading shows no error toast afterwards.
  • In another language (Portuguese, German), the dialog's copy is translated and fits.
  • With a wrong GIPHY_API_KEY, the dialog shows the error message instead of an empty result.
  • With GIPHY_ENABLED=false, or without a key, GIPHY is gone from the media menu.
  • .env.example and docker/.env.docker.example list only GIPHY_ENABLED and GIPHY_API_KEY.

Unsplash

  • Picking a photo closes the dialog, the photo shows loading in the post, then appears; the photographer's credit is kept on the media (the dialog shows it, the post does not).
  • The download tracking request reaches Unsplash once the photo landed (Telescope, HTTP client).
  • Picked on a thread reply, the photo lands on that reply.
  • Picked in the idea editor, the photo joins the idea.
  • Search and scrolling in the Unsplash dialog still work.
  • A photo without a photographer link still imports, with the credit shown without a link (the real API always sends the link; covered by MediaUploadControllerTest).
  • Without UNSPLASH_ACCESS_KEY, Unsplash is gone from the media menu.

Replace link preview with media

  • On a post with a link that has a preview image (LinkedIn, Bluesky or Facebook), "Replace link preview with media" keeps its button busy until the image appears, and the tile shows the link's domain while it loads.
  • Once the image lands, the link card is replaced by the image.
  • With Customize for each network, the image lands on the card whose link was replaced, not on the others.
  • Clicking the button twice quickly adds the image once.
  • A link without a preview image toasts "This link has no image to use."
  • A link whose preview image no longer loads (a 404 image) shows the error tile instead of hanging.

Imports through the queue and the socket

  • A Google Drive pick shows loading, then the file, and Network shows no GET media/imports/{id} repeating every 1.5 seconds (one read when the tile appears and one when the import settles).
  • In DevTools (Network, WS), the Reverb socket receives media.import.settled on private-workspace.{id} carrying only the import_id, never the file or its URL.
  • A large Google Drive video that takes more than a minute to download still lands in the post (what the in-request import could not do).
  • Several Google Photos items picked together each land in their own tile.
  • A Canva design and "Edit in Canva" still land in the post.
  • With Horizon stopped, a picked GIF stays loading; starting Horizon makes it appear without reloading the page.
  • With Reverb stopped while an import finishes, the tile stays loading; starting Reverb again makes it appear without reloading the page.
  • A file the import refuses shows the error tile with its reason (seen live with a link preview image answering 404; the over-cap case is covered by MediaUploadControllerTest and GiphyControllerTest).
  • Turning GIPHY off while its dialog is open and picking a GIF toasts the reason and keeps the dialog open.
  • Another member of the same workspace, with the composer open, sees no tile from someone else's import (seen live with a second tab of the same user, which hears the event and shows nothing; the status endpoint answers its starter only).
  • The same user with the composer open in a second tab sees no tile there from the first tab's import.

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
Sorvereign force-pushed the feat/linkedin-accepts-gif branch from 2ba083d to f0e0047 Compare November 18, 2026 15:20
@paulocastellano

Copy link
Copy Markdown
Contributor

Thank you @Sorvereign i will review it soon.

paulocastellano and others added 3 commits November 18, 2026 16:15
- 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).
@paulocastellano paulocastellano changed the title Accept animated GIFs on LinkedIn posts Accept animated GIFs on LinkedIn posts and add GIPHY to the composer Nov 18, 2026
Paulo Castellano 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.
Paulo Castellano 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.
@paulocastellano paulocastellano changed the title Accept animated GIFs on LinkedIn posts and add GIPHY to the composer Accept GIFs on LinkedIn, add GIPHY to the composer, and settle media imports over the socket Nov 18, 2026
Paulo Castellano 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.
@paulocastellano
paulocastellano merged commit 63eedd5 into trypostit:main Nov 19, 2026
17 of 19 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Import Unsplash photos through the media import queue

2 participants