summaryrefslogtreecommitdiff
path: root/docs/config/howto_set_richmedia_cache_ttl_based_on_image.md
diff options
context:
space:
mode:
authorkaniini <ariadne@dereferenced.org>2019-07-19 21:36:36 +0000
committerkaniini <ariadne@dereferenced.org>2019-07-19 21:36:36 +0000
commit33729bbb2834bfa1f223b11d47dc8e3230d47657 (patch)
treec168dab53cb5868f7c0939f99e20f031124a1d54 /docs/config/howto_set_richmedia_cache_ttl_based_on_image.md
parentc1c64d6d06fb7307245880d6605d9d9153a4784f (diff)
parent581756ccc50cc08823957a2f24f506bf23c7cd22 (diff)
downloadpleroma-33729bbb2834bfa1f223b11d47dc8e3230d47657.tar.gz
pleroma-33729bbb2834bfa1f223b11d47dc8e3230d47657.zip
Merge branch 'feature/richmedia-ttl' into 'develop'
add the rich media ttl based on image exp time See merge request pleroma/pleroma!1438
Diffstat (limited to 'docs/config/howto_set_richmedia_cache_ttl_based_on_image.md')
-rw-r--r--docs/config/howto_set_richmedia_cache_ttl_based_on_image.md33
1 files changed, 33 insertions, 0 deletions
diff --git a/docs/config/howto_set_richmedia_cache_ttl_based_on_image.md b/docs/config/howto_set_richmedia_cache_ttl_based_on_image.md
new file mode 100644
index 000000000..bfee5a9e6
--- /dev/null
+++ b/docs/config/howto_set_richmedia_cache_ttl_based_on_image.md
@@ -0,0 +1,33 @@
+# How to set rich media cache ttl based on image ttl
+## Explanation
+
+Richmedia are cached without the ttl but the rich media may have image which can expire, like aws signed url.
+In such cases the old image url (expired) is returned from the media cache.
+
+So to avoid such situation we can define a module that will set ttl based on image.
+The module must adopt behaviour `Pleroma.Web.RichMedia.Parser.TTL`
+
+### Example
+
+```exs
+defmodule MyModule do
+ @behaviour Pleroma.Web.RichMedia.Parser.TTL
+
+ @impl Pleroma.Web.RichMedia.Parser.TTL
+ def ttl(data, url) do
+ image_url = Map.get(data, :image)
+ # do some parsing in the url and get the ttl of the image
+ # return ttl is unix time
+ parse_ttl_from_url(image_url)
+ end
+end
+```
+
+And update the config
+
+```exs
+config :pleroma, :rich_media,
+ ttl_setters: [Pleroma.Web.RichMedia.Parser.TTL.AwsSignedUrl, MyModule]
+```
+
+> For reference there is a parser for AWS signed URL `Pleroma.Web.RichMedia.Parser.TTL.AwsSignedUrl`, it's enabled by default.