Consider nicknames when searching for messages (#4663)

Co-authored-by: pajlada <rasmus.karlsson+github@pajlada.com>
This commit is contained in:
chrrs
2023-05-31 21:38:17 +02:00
committed by GitHub
parent e9432d3b65
commit bf4148a370
8 changed files with 39 additions and 18 deletions
+8 -8
View File
@@ -3,6 +3,7 @@
#include "util/RapidjsonHelpers.hpp"
#include "util/RapidJsonSerializeQString.hpp"
#include <boost/optional.hpp>
#include <pajlada/serialize.hpp>
#include <QRegularExpression>
#include <QString>
@@ -58,25 +59,25 @@ public:
return this->isCaseSensitive_;
}
[[nodiscard]] bool match(QString &usernameText) const
[[nodiscard]] boost::optional<QString> match(
const QString &usernameText) const
{
if (this->isRegex())
{
if (!this->regex_.isValid())
{
return false;
return boost::none;
}
if (this->name().isEmpty())
{
return false;
return boost::none;
}
auto workingCopy = usernameText;
workingCopy.replace(this->regex_, this->replace());
if (workingCopy != usernameText)
{
usernameText = workingCopy;
return true;
return workingCopy;
}
}
else
@@ -85,12 +86,11 @@ public:
this->name().compare(usernameText, this->caseSensitivity());
if (res == 0)
{
usernameText = this->replace();
return true;
return this->replace();
}
}
return false;
return boost::none;
}
private: