aboutsummaryrefslogtreecommitdiffstats
path: root/web/widget-api.js
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2020-09-05 17:19:25 +0300
committerTulir Asokan <tulir@maunium.net>2020-09-05 17:19:25 +0300
commit6e6aad0430686189f155193e74db5bedad1bcca0 (patch)
treef5851af2002474ffac5b273535ceaf479635ff5b /web/widget-api.js
parent47f3d3fdee2445a5f87b9e04971e820e234a5e59 (diff)
Add more Element iOS compatibility (ref #8)
Diffstat (limited to 'web/widget-api.js')
-rw-r--r--web/widget-api.js22
1 files changed, 18 insertions, 4 deletions
diff --git a/web/widget-api.js b/web/widget-api.js
index 556537f..6d81107 100644
--- a/web/widget-api.js
+++ b/web/widget-api.js
@@ -34,14 +34,28 @@ window.onmessage = event => {
}
export function sendSticker(content) {
+ const data = {
+ content,
+ // `name` is for Element Web (and also the spec)
+ // Element Android uses content -> body as the name
+ name: content.body,
+ }
+
+ // This is for Element iOS
+ const widgetData = {
+ ...data,
+ description: content.body,
+ file: `${content["net.maunium.telegram.sticker"].id}.png`,
+ }
+ // Element iOS explodes if there are extra fields present
+ delete widgetData.content["net.maunium.telegram.sticker"]
+
window.parent.postMessage({
api: "fromWidget",
action: "m.sticker",
requestId: `sticker-${Date.now()}`,
widgetId,
- data: {
- name: content.body,
- content,
- },
+ data,
+ widgetData,
}, "*")
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage