mirror of
https://github.com/maunium/stickerpicker.git
synced 2025-01-30 20:05:04 +01:00
Add more Element iOS compatibility (ref #8)
This commit is contained in:
parent
47f3d3fdee
commit
6e6aad0430
@ -3,7 +3,7 @@
|
|||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
from typing import Dict, TypedDict
|
from typing import Dict, TypedDict, Optional
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
import argparse
|
import argparse
|
||||||
import os.path
|
import os.path
|
||||||
@ -75,6 +75,8 @@ class MatrixMediaInfo(TypedDict):
|
|||||||
h: int
|
h: int
|
||||||
size: int
|
size: int
|
||||||
mimetype: str
|
mimetype: str
|
||||||
|
thumbnail_url: Optional[str]
|
||||||
|
thumbnail_info: Optional['MatrixMediaInfo']
|
||||||
|
|
||||||
|
|
||||||
class MatrixStickerInfo(TypedDict, total=False):
|
class MatrixStickerInfo(TypedDict, total=False):
|
||||||
@ -122,6 +124,7 @@ async def reupload_document(client: TelegramClient, document: Document) -> Matri
|
|||||||
"w": width,
|
"w": width,
|
||||||
"h": height,
|
"h": height,
|
||||||
"size": len(data),
|
"size": len(data),
|
||||||
|
"mimetype": "image/png",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -34,14 +34,28 @@ window.onmessage = event => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function sendSticker(content) {
|
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({
|
window.parent.postMessage({
|
||||||
api: "fromWidget",
|
api: "fromWidget",
|
||||||
action: "m.sticker",
|
action: "m.sticker",
|
||||||
requestId: `sticker-${Date.now()}`,
|
requestId: `sticker-${Date.now()}`,
|
||||||
widgetId,
|
widgetId,
|
||||||
data: {
|
data,
|
||||||
name: content.body,
|
widgetData,
|
||||||
content,
|
|
||||||
},
|
|
||||||
}, "*")
|
}, "*")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user