spc-pleroma/lib/pleroma/web
Mark Felder a6407f9ba5 RichMedia refactor
Rich Media parsing was previously handled on-demand with a 2 second HTTP request timeout and retained only in Cachex. Every time a Pleroma instance is restarted it will have to request and parse the data for each status with a URL detected. When fetching a batch of statuses they were processed in parallel to attempt to keep the maximum latency at 2 seconds, but often resulted in a timeline appearing to hang during loading due to a URL that could not be successfully reached. URLs which had images links that expire (Amazon AWS) were parsed and inserted with a TTL to ensure the image link would not break.

Rich Media data is now cached in the database and fetched asynchronously. Cachex is used as a read-through cache. When the data becomes available we stream an update to the clients. If the result is returned quickly the experience is almost seamless. Activities were already processed for their Rich Media data during ingestion to warm the cache, so users should not normally encounter the asynchronous loading of the Rich Media data.

Implementation notes:

- The async worker is a Task with a globally unique process name to prevent duplicate processing of the same URL
- The Task will attempt to fetch the data 3 times with increasing sleep time between attempts
- The HTTP request obeys the default HTTP request timeout value instead of 2 seconds
- URLs that cannot be successfully parsed due to an unexpected error receives a negative cache entry for 15 minutes
- URLs that fail with an expected error will receive a negative cache with no TTL
- Activities that have no detected URLs insert a nil value in the Cachex :scrubber_cache so we do not repeat parsing the object content with Floki every time the activity is rendered
- Expiring image URLs are handled with an Oban job
- There is no automatic cleanup of the Rich Media data in the database, but it is safe to delete at any time
- The post draft/preview feature makes the URL processing synchronous so the rendered post preview will have an accurate rendering

Overall performance of timelines and creating new posts which contain URLs is greatly improved.
2024-05-05 13:51:13 -04:00
..
activity_pub RichMedia refactor 2024-05-05 13:51:13 -04:00
admin_api Pleroma.Web.AdminAPI.UserController: fix dialyzer errors with replace_params: false 2024-01-30 17:51:40 -05:00
api_spec Merge branch 'develop' into 'bookmark-folders' 2024-03-18 10:35:02 +00:00
auth Fix invalid type 2024-01-20 17:33:37 -05:00
channels Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
common_api Credo.Check.Readability.PredicateFunctionNames 2024-01-26 16:59:58 -05:00
fallback RedirectController: Unify server-generated-meta insertion code 2023-11-14 11:06:36 +01:00
federator Retire the Pleroma.Web.Federator.Publisher module 2023-12-28 14:53:09 -05:00
feed Fix invalid types due to typos 2024-01-20 17:22:40 -05:00
mailer Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
mastodon_api RichMedia refactor 2024-05-05 13:51:13 -04:00
media_proxy Pleroma.Web.MediaProxy.MediaProxyController: dialyzer errors 2024-01-29 18:50:50 -05:00
metadata twitter card: handle case where image has no alt text 2023-05-29 02:52:49 +05:00
mongoose_im Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
nodeinfo Remove support for multiple federation publisher modules 2023-12-28 11:55:19 -05:00
o_auth Pleroma.Web.OAuth.OAuthController: dialyzer error 2024-01-31 11:29:06 -05:00
o_status Fix dialyzer errors due to deprecated usage of put_layout/2 2024-01-31 14:55:11 -05:00
pleroma_api RichMedia refactor 2024-05-05 13:51:13 -04:00
plugs Pleroma.Web.Plugs.RateLimiter.Supervisor: dialyzer error 2024-01-31 13:12:56 -05:00
preload/providers Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
push Elixir 1.15: Chase the Logger.warn deprecation 2023-12-20 20:16:26 +00:00
rich_media RichMedia refactor 2024-05-05 13:51:13 -04:00
static_fe Fix dialyzer errors due to deprecated usage of put_layout/2 2024-01-31 14:55:11 -05:00
templates Use User.full_nickname/1 in oauth html template 2024-02-09 16:46:45 +01:00
twitter_api Pleroma.Web.TwitterAPI.UtilController: fix dialyzer errors with replace_params: false 2024-01-31 10:13:02 -05:00
utils Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
views Use pleroma: instead of pleroma. for ws events 2023-10-15 17:20:25 -04:00
web_finger Phoenix detects the webfinger requests with content-type application/jrd+json as "jrd" now 2023-12-29 23:18:45 -05:00
api_spec.ex Allow to group bookmarks in folders 2024-03-01 11:04:01 +01:00
common_api.ex Credo.Check.Readability.PredicateFunctionNames 2024-01-26 16:59:58 -05:00
controller_helper.ex Pleroma.Web.ControllerHelper: fix @spec to resolve dialyzer errors 2024-01-31 11:01:37 -05:00
embed_controller.ex Fix dialyzer errors due to deprecated usage of put_layout/2 2024-01-31 14:55:11 -05:00
endpoint.ex Force more frequent full_sweep GC runs on the Websocket processes 2024-02-17 09:53:52 -05:00
federator.ex Fix the Federator perform/2 Oban callback 2023-12-28 22:51:47 -05:00
gettext.ex Credo.Check.Readability.PredicateFunctionNames 2024-01-26 16:59:58 -05:00
instance_document.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
manifest_controller.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
media_proxy.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
metadata.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
multipart.ex endpoint: Use custom Multipart module for dynamic configuration 2023-06-27 10:41:25 +02:00
o_auth.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
plug.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
preload.ex B Preload: Make sure that the preloaded json is html safe 2023-06-02 17:03:21 +04:00
push.ex Elixir 1.15: Chase the Logger.warn deprecation 2023-12-20 20:16:26 +00:00
rel_me.ex Remove unwanted code specific to MIX_ENV=test 2023-02-20 12:24:38 -05:00
router.ex Allow to group bookmarks in folders 2024-03-01 11:04:01 +01:00
shout_channel.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
streamer.ex Credo.Check.Readability.PredicateFunctionNames 2024-01-26 16:59:58 -05:00
translation_helpers.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
uploader_controller.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
web_finger.ex Remove support for multiple federation publisher modules 2023-12-28 11:55:19 -05:00
xml.ex Completely disable xml entity resolution 2023-08-05 14:17:04 +02:00