pleroma/lib/pleroma
Mark Felder ede414094f 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-07 19:54:56 -04:00
..
activity Fix Rich Media Previews for updated activities 2024-02-04 23:47:04 -05:00
captcha Fix some more typos 2023-12-28 00:17:04 +01:00
chat Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
config Config: Check the permissions of the linked file instead of the symlink↵ 2024-02-14 18:19:50 +01:00
conversation Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
docs Fix invalid type 2024-01-20 17:05:55 -05:00
ecto_type Dialyzer: fix pattern match coverage 2024-01-20 17:56:32 -05:00
emails Revert "EmailTest: use config mock" 2023-12-12 19:35:19 +04:00
emoji Pleroma.Emoji.Pack: fix gradient error 2024-02-02 12:14:21 -05:00
gopher Credo.Check.Readability.PredicateFunctionNames 2024-01-26 16:59:58 -05:00
gun Rename variable to make the worker retry logic easier to read 2024-02-23 11:12:10 -05:00
helpers MediaHelper: cache failed URLs for 15 minutes to prevent excessive retries 2024-03-19 12:14:03 -04:00
http Pleroma.HTTP.RequestBuilder: fix gradient error 2024-02-02 12:14:21 -05:00
instances Elixir 1.15: Chase the Logger.warn deprecation 2023-12-20 20:16:26 +00:00
mfa Pleroma.MFA.Totp.provisioning_uri/3: add @spec 2024-02-02 12:13:31 -05:00
migration_helper Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
migrators Pleroma.Migrators.Support.BaseMigrator: Fix dialyzer errors 2024-01-22 18:37:13 -05:00
object Handle 401s as I have observed it in the wild 2023-12-28 23:09:33 -05:00
password Fix atom leak in password digest functionality 2024-02-14 17:54:56 -05:00
reverse_proxy Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
search Remove vestiges of old Postgres support 2024-03-18 15:42:15 -04:00
telemetry Change some Gun connection pool logs to debug level 2024-02-14 13:28:32 -05:00
tesla/middleware Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
tests Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
upload Elixir 1.15: Chase the Logger.warn deprecation 2023-12-20 20:16:26 +00:00
uploaders Use config to control Uploader callback timeout 2024-01-22 18:37:13 -05:00
user Include following/followers in backups 2024-03-10 23:53:12 +01:00
web RichMedia refactor 2024-05-07 19:54:56 -04:00
workers RichMedia refactor 2024-05-07 19:54:56 -04:00
activity.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
announcement.ex Announcement: fix dialyzer errors and add typespec for the changeset 2024-01-22 18:37:13 -05:00
announcement_read_relationship.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
application.ex MediaHelper: cache failed URLs for 15 minutes to prevent excessive retries 2024-03-19 12:14:03 -04:00
application_requirements.ex Pleroma.ApplicationRequirements: fix dialyzer errors 2024-01-20 16:10:11 -05:00
bookmark.ex Allow to group bookmarks in folders 2024-03-01 11:04:01 +01:00
bookmark_folder.ex Allow to group bookmarks in folders 2024-03-01 11:04:01 +01:00
caching.ex Pleroma.Web.RichMedia.Parser: Remove test-specific codepaths 2024-02-06 18:33:54 -05:00
captcha.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
chat.ex FlakeId.Ecto.CompatType.t() does not exist 2024-01-20 16:36:01 -05:00
clippy.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
config.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
config_db.ex Fix invalid typespec references to Ecto.Changeset.t() 2024-01-20 16:47:50 -05:00
constants.ex Allow local user to have group actor type 2023-12-27 12:27:37 -05:00
conversation.ex Credo.Check.Readability.PredicateFunctionNames 2024-01-26 16:59:58 -05:00
counter_cache.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
data_migration.ex Pleroma.Migrators.Support.BaseMigratorState: fix dialyzer error 2024-01-22 18:37:13 -05:00
delivery.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
ecto_enums.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
emoji-test.txt emoji-test: update to latest 15.0 draft 2022-08-20 00:21:07 +02:00
emoji.ex Merge branch 'deps-bump' into 'develop' 2024-01-29 17:43:00 +00:00
filter.ex Pleroma.Filter: fix gradient error 2024-02-02 12:14:21 -05:00
following_relationship.ex Notifications: filter on users rather than activities 2024-03-17 20:58:59 +01:00
formatter.ex Fix mentioning punycode domains when using Markdown 2023-10-16 21:35:25 -04:00
frontend.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
gun.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
hashtag.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
healthcheck.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
html.ex RichMedia refactor 2024-05-07 19:54:56 -04:00
http.ex Fix following redirects with Finch 2023-12-29 00:50:50 -05:00
instances.ex These functions in Pleroma.Instances should be defdelegates to Pleroma.Instances.Instance 2023-12-27 12:44:16 -05:00
job_queue_monitor.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
jwt.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
keys.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
list.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
logging.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
maintenance.ex Elixir 1.15: Chase the Logger.warn deprecation 2023-12-20 20:16:26 +00:00
maps.ex Maps: Add filter_empty_values/1 2024-01-26 16:18:29 +01:00
marker.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
mfa.ex Pleroma.MFA: fix gradient error 2024-02-02 12:14:15 -05:00
moderation_log.ex Formatting 2024-01-27 10:09:20 -05:00
notification.ex Notifications: filter on users rather than activities 2024-03-17 20:58:59 +01:00
object.ex Pleroma.Object: dialyzer error 2024-01-27 13:58:50 -05:00
object_tombstone.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
otp_version.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
pagination.ex Pleroma.Web.MastodonAPI.SearchController: fix dialyzer errors 2024-01-31 11:12:41 -05:00
password_reset_token.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
prom_ex.ex Switch to PromEx for prometheus metrics 2023-11-13 15:34:59 -05:00
registration.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
release_tasks.ex Dialyzer: fix pattern match coverage 2024-01-20 17:58:47 -05:00
repo.ex Switch to PromEx for prometheus metrics 2023-11-13 15:34:59 -05:00
report_note.ex Fix invalid typespec references to Ecto.Changeset.t() 2024-01-20 16:47:50 -05:00
reverse_proxy.ex MediaProxy RFC compliance 2024-02-14 13:25:52 -05:00
scheduled_activity.ex ScheduledActivity: Use config mocking 2023-12-12 12:48:55 +04:00
search.ex Don't try removing deleted users and such from index as posts 2022-10-10 20:19:09 +03:00
signature.ex Pleroma.Signature: dialyzer error 2024-01-26 21:03:41 -05:00
stats.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
thread_mute.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
upload.ex MascotController dialyzer error 2024-01-31 10:13:02 -05:00
user.ex Merge remote-tracking branch 'origin/develop' into link-verification 2024-03-07 13:13:49 +01:00
user_invite_token.ex Fix invalid typespec references to Ecto.Changeset.t() 2024-01-20 16:47:50 -05:00
user_note.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
user_relationship.ex Pleroma.User: fix dialyzer errors 2024-01-22 18:37:13 -05:00
utils.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00
web.ex Fix deprecated calls to get_flash/2 2023-05-31 13:36:21 -04:00
xml_builder.ex Revert "Merge branch 'copyright-bump' into 'develop'" 2023-01-02 20:38:50 +00:00