From 5fd3a7a1e1d5f2eba61d7e3bc05d9b7e9c2878ea Mon Sep 17 00:00:00 2001 From: Travis Ralston <travpc@gmail.com> Date: Thu, 12 Apr 2018 16:33:30 -0600 Subject: [PATCH] Make sure usernames don't overflow the length requirement --- src/bot.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bot.ts b/src/bot.ts index 45bd0e3..3c0fe9f 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -19,6 +19,8 @@ import { Provisioner } from "./provisioner"; const MSG_PROCESS_DELAY = 750; const MIN_PRESENCE_UPDATE_DELAY = 250; const AVATAR_SIZE = 512; // matrix -> discord +const MAX_DISCORD_NAME_LENGTH = 32; +const DISCORD_NAME_START = 0; // TODO: This is bad. We should be serving the icon from the own homeserver. const MATRIX_ICON_URL = "https://matrix.org/_matrix/media/r0/download/matrix.org/mlxoESwIsTbJrfXyAAogrNxA"; class ChannelLookupResult { @@ -181,7 +183,7 @@ export class DiscordBot { */ return new Discord.RichEmbed({ author: { - name: profile.displayname, + name: profile.displayname.substring(DISCORD_NAME_START, MAX_DISCORD_NAME_LENGTH), icon_url: profile.avatar_url, url: `https://matrix.to/#/${event.sender}`, }, -- GitLab