From 7aedd3d9e9008abc42ba5bfc956b12320bea7aaf Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Sun, 11 Sep 2022 19:07:29 +0100 Subject: [PATCH] inline files rfc (#1024) --- docs/rfcs/2022-09-06-send-small-files.md | 55 ++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 docs/rfcs/2022-09-06-send-small-files.md diff --git a/docs/rfcs/2022-09-06-send-small-files.md b/docs/rfcs/2022-09-06-send-small-files.md new file mode 100644 index 0000000000..221f851b6f --- /dev/null +++ b/docs/rfcs/2022-09-06-send-small-files.md @@ -0,0 +1,55 @@ +# Sending small files + +## Problem + +Sending files has a substantial constant overhead, and requires multiple online presenses from both sides, with additional connection handshake. For large files this overhead is justified, as otherwise files would consume queue quota, but for small files it makes sending files slow. + +## Solution + +Send small files in the same connection. There can be two modes of sending files - the one that requires explicit acceptance, but after the acceptance the file will be delivered inline, without creating a new conneciton. Another, when the file will be sent straight after the message - that would require preliminary agreement, per contact - this mode can be useful for small voice messages and gifs. + +## Design + +1. Add optional `fileInline :: Maybe FileInlineMode` property to `FileInvitation`: + +```haskell +data FileInlineMode + = FIInvitation -- recepient must accept + | FIChunks -- file is sent after the message without acceptance +``` + +2. Add `XFileAcptInline SharedMsgId String` message to accept inline files, this can only be sent in case inline mode is offered, so the sender would support it: + +``` +{ + "properties": { + "type": {"enum": ["x.file.acpt.inline"]}, + "msgId": {"ref": "base64url"}, + "params": { + "properties": { + "msgId": {"ref": "base64url"}, + "fileName": {"type": "string"} + } + } + } +} +``` + +3. Add `XFileChunks` message that have to be sent in front of the sequence of chunks (sent only in `FIInvitation` mode): + +``` +{ + "properties": { + "type": {"enum": ["x.file.chunks"]}, + "msgId": {"ref": "base64url"}, + "params": { + "properties": { + "msgId": {"ref": "base64url"}, + "fileName": {"type": "string"} + } + } + } +} +``` + +4. Support file chunks in the main connection if the previous message was `XFileChunks` or `FileInvitation` in `FIChunks` mode.