File indexing completed on 2024-12-01 04:37:01

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "roomutil.h"
0008 #include "ruqolawidgets_debug.h"
0009 QString RoomUtil::generateUserLink(const QString &userName)
0010 {
0011     return QStringLiteral("ruqola:/user/") + userName;
0012 }
0013 
0014 QString RoomUtil::generatePermalink(const QString &messageId, const QString &roomId, Room::RoomType channelType)
0015 {
0016     QString prefix;
0017     switch (channelType) {
0018     case Room::RoomType::Channel:
0019         prefix = QStringLiteral("channel/");
0020         break;
0021     case Room::RoomType::Direct:
0022         prefix = QStringLiteral("direct/");
0023         break;
0024     case Room::RoomType::Private:
0025         prefix = QStringLiteral("group/");
0026         break;
0027     case Room::RoomType::Unknown:
0028         qCWarning(RUQOLAWIDGETS_LOG) << " channel type undefined " << channelType;
0029         break;
0030     }
0031     const QString result = QStringLiteral("%1%2?msg=%3").arg(prefix, roomId, messageId);
0032     return result;
0033 }
0034 
0035 bool RoomUtil::validUser(const QString &userName)
0036 {
0037     return (userName != QLatin1String("here") && userName != QLatin1String("all"));
0038 }