From 0bfcd955e332f9ba1022bdce104489492009bd9c Mon Sep 17 00:00:00 2001 From: Nachtalb Date: Thu, 6 May 2021 02:02:23 +0200 Subject: [PATCH 1/6] Improve inline audio file support Tested on latest Chromium / Firefox. In case of .m4a files they want audio/x-m4a and not audio/m4a, in case of .flac files they want audio/flac and not audio/x-flac. The module we useed to detect the types however detects them only as audio/x-m4a and audio/x-flac as they are not offical IANA supported mime types (not in IANA spec == "x-" prefix): https://www.iana.org/assignments/media-types/media-types.xhtml Though flac is not in the IANA spec many programs such as the file command (https://man7.org/linux/man-pages/man1/file.1.html) and Chromium (flac) / Firefox (x-flac and flac) support audio/flac only or both. --- src/plugins/irc-events/link.js | 2 ++ src/plugins/uploader.js | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plugins/irc-events/link.js b/src/plugins/irc-events/link.js index e268d9ef..c21a18dc 100644 --- a/src/plugins/irc-events/link.js +++ b/src/plugins/irc-events/link.js @@ -249,6 +249,8 @@ function parse(msg, chan, preview, res, client) { case "audio/x-midi": case "audio/x-mpeg": case "audio/x-mpeg-3": + case "audio/flac": + case "audio/x-m4a": if (!preview.link.startsWith("https://")) { break; } diff --git a/src/plugins/uploader.js b/src/plugins/uploader.js index 249aa579..6f24b6f5 100644 --- a/src/plugins/uploader.js +++ b/src/plugins/uploader.js @@ -21,7 +21,8 @@ const inlineContentDispositionTypes = { "audio/mpeg": "audio.mp3", "audio/ogg": "audio.ogg", "audio/vnd.wave": "audio.wav", - "audio/flac": "audio.flac", + "audio/x-flac": "audio.flac", + "audio/x-m4a": "audio.m4a", "image/bmp": "image.bmp", "image/gif": "image.gif", "image/jpeg": "image.jpg", @@ -110,10 +111,12 @@ class Uploader { }); } + // Send a more common mime type for audio files + // so that browsers can play them correctly if (detectedMimeType === "audio/vnd.wave") { - // Send a more common mime type for wave audio files - // so that browsers can play them correctly detectedMimeType = "audio/wav"; + } else if (detectedMimeType === "audio/x-flac") { + detectedMimeType = "audio/flac"; } res.setHeader("Content-Disposition", disposition); From b95643e1a6f4283e3ae4aa86b92741b4329b0b6b Mon Sep 17 00:00:00 2001 From: Nachtalb Date: Thu, 6 May 2021 02:48:07 +0200 Subject: [PATCH 2/6] Allow text drag & drop into text fields We only have to stop the defualt behaviour in case we drag & drop a file (for uploading) --- client/js/upload.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/client/js/upload.js b/client/js/upload.js index faec57e6..e5e3e6f9 100644 --- a/client/js/upload.js +++ b/client/js/upload.js @@ -26,31 +26,36 @@ class Uploader { } dragOver(event) { - // Prevent dragover event completely and do nothing with it - // This stops the browser from trying to guess which cursor to show - event.preventDefault(); + if (event.dataTransfer.types.includes("Files")) { + // Prevent dragover event completely and do nothing with it + // This stops the browser from trying to guess which cursor to show + event.preventDefault(); + } } dragEnter(event) { - event.preventDefault(); - // relatedTarget is the target where we entered the drag from // when dragging from another window, the target is null, otherwise its a DOM element if (!event.relatedTarget && event.dataTransfer.types.includes("Files")) { + event.preventDefault(); + this.overlay.classList.add("is-dragover"); } } dragLeave(event) { - event.preventDefault(); - // If relatedTarget is null, that means we are no longer dragging over the page if (!event.relatedTarget) { + event.preventDefault(); this.overlay.classList.remove("is-dragover"); } } drop(event) { + if (!event.dataTransfer.types.includes("Files")) { + return; + } + event.preventDefault(); this.overlay.classList.remove("is-dragover"); From a3229f1cdf5571ded500fc88bc64f94605cb1834 Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Wed, 5 May 2021 21:51:35 -0400 Subject: [PATCH 3/6] classes for unread and highlight --- client/components/ChannelWrapper.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/components/ChannelWrapper.vue b/client/components/ChannelWrapper.vue index c979007f..35f9e656 100644 --- a/client/components/ChannelWrapper.vue +++ b/client/components/ChannelWrapper.vue @@ -8,6 +8,8 @@ {active: active}, {'parted-channel': channel.type === 'channel' && channel.state === 0}, {'has-draft': channel.pendingMessage}, + {'has-unread': channel.unread}, + {'has-highlight': channel.highlight}, { 'not-secure': channel.type === 'lobby' && network.status.connected && !network.status.secure, From a985d763d0bb8398de7ecc120e785b6686e8aafa Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 7 May 2021 02:13:33 +0000 Subject: [PATCH 4/6] Update dependency ua-parser-js to v0.7.24 [SECURITY] --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index cd6dc8c8..aa34c0ed 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "sharp": "0.28.0", "socket.io": "3.1.2", "tlds": "1.216.0", - "ua-parser-js": "0.7.23", + "ua-parser-js": "0.7.24", "uuid": "8.3.2", "web-push": "3.4.4", "yarn": "1.22.10" diff --git a/yarn.lock b/yarn.lock index da8bc1ee..cc0817fb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8290,10 +8290,10 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" -ua-parser-js@0.7.23: - version "0.7.23" - resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.23.tgz#704d67f951e13195fbcd3d78818577f5bc1d547b" - integrity sha512-m4hvMLxgGHXG3O3fQVAyyAQpZzDOvwnhOTjYz5Xmr7r/+LpkNy3vJXdVRWgd1TkAb7NGROZuSy96CrlNVjA7KA== +ua-parser-js@0.7.24: + version "0.7.24" + resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.24.tgz#8d3ecea46ed4f1f1d63ec25f17d8568105dc027c" + integrity sha512-yo+miGzQx5gakzVK3QFfN0/L9uVhosXBBO7qmnk7c2iw1IhL212wfA3zbnI54B0obGwC/5NWub/iT9sReMx+Fw== uc.micro@^1.0.1: version "1.0.6" From 042cfb75824c13039c6f82af4cfa7ecba0bd92a5 Mon Sep 17 00:00:00 2001 From: Nachtalb Date: Sun, 9 May 2021 23:32:11 +0200 Subject: [PATCH 5/6] Fix missing users in userlist after removing searchinput Because the "Username" components still had the same ":key" vue tried to in-place update them. This doesn't quite work for objects (in this case "user" or "user.original"). Thus we change the key for the search so that it actually inits a new component and thus evaluates its content correctly. --- client/components/ChatUserList.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/components/ChatUserList.vue b/client/components/ChatUserList.vue index 2bc19696..bbb4f4f5 100644 --- a/client/components/ChatUserList.vue +++ b/client/components/ChatUserList.vue @@ -28,7 +28,7 @@