From 85c20aaeb90ef0e0f44c377e62c323fde275cdde Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 11 May 2023 16:16:27 +0200 Subject: Set actor preferred name case insensitive --- server/models/video/video-channel.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'server/models/video') diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 67fccab68..306bc6ade 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts @@ -130,13 +130,16 @@ export type SummaryOptions = { for (const handle of options.handles || []) { const [ preferredUsername, host ] = handle.split('@') + const sanitizedPreferredUsername = VideoChannelModel.sequelize.escape(preferredUsername.toLowerCase()) + const sanitizedHost = VideoChannelModel.sequelize.escape(host) + if (!host || host === WEBSERVER.HOST) { - or.push(`("preferredUsername" = ${VideoChannelModel.sequelize.escape(preferredUsername)} AND "serverId" IS NULL)`) + or.push(`(LOWER("preferredUsername") = ${sanitizedPreferredUsername} AND "serverId" IS NULL)`) } else { or.push( `(` + - `"preferredUsername" = ${VideoChannelModel.sequelize.escape(preferredUsername)} ` + - `AND "host" = ${VideoChannelModel.sequelize.escape(host)}` + + `LOWER("preferredUsername") = ${sanitizedPreferredUsername} ` + + `AND "host" = ${sanitizedHost}` + `)` ) } @@ -698,8 +701,10 @@ export class VideoChannelModel extends Model