diff options
author | Maxim Nikolenko <maximnproductengine@lindenlab.com> | 2025-07-29 18:47:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-29 18:47:44 +0300 |
commit | 514b658fde13bb0c0ec862b081eeebf47bace70d (patch) | |
tree | 73224d97f9588cf673b3f0cdd79c3d62c798919c /indra/newview | |
parent | 3b8b408b9031f295a936eb5e3342fbb7eb671c7c (diff) |
#4385 show agent name next to @ mention url in chat logs
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/lllogchat.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp index fbf4a7d1dd..76d3c8cea2 100644 --- a/indra/newview/lllogchat.cpp +++ b/indra/newview/lllogchat.cpp @@ -32,6 +32,8 @@ #include "lllogchat.h" #include "llregex.h" #include "lltrans.h" +#include "llurlaction.h" +#include "llurlentry.h" #include "llviewercontrol.h" #include "lldiriterator.h" @@ -358,13 +360,29 @@ void LLLogChat::saveHistory(const std::string& filename, return; } + std::string altered_line = line; + + // avoid costly regex calls + if (line.find("/mention") != std::string::npos) + { + static const boost::regex mention_regex(APP_HEADER_REGEX "/agent/[\\da-f-]+/mention", boost::regex::perl | boost::regex::icase); + + // replace mention URL with [@username](URL) + altered_line = boost::regex_replace(line, mention_regex, [](const boost::smatch& match) -> std::string + { + std::string url = match[0].str(); + std::string username = LLUrlAction::getURLLabel(url); + return "[" + username + "](" + url + ")"; + }); + } + LLSD item; if (gSavedPerAccountSettings.getBOOL("LogTimestamp")) item["time"] = LLLogChat::timestamp2LogString(0, gSavedPerAccountSettings.getBOOL("LogTimestampDate")); item["from_id"] = from_id; - item["message"] = line; + item["message"] = altered_line; //adding "Second Life:" for all system messages to make chat log history parsing more reliable if (from.empty() && from_id.isNull()) @@ -470,6 +488,19 @@ void LLLogChat::loadChatHistory(const std::string& file_name, std::list<LLSD>& m std::string line(remove_utf8_bom(buffer)); + + // fast heuristic test for a mention URL in a string + // this is used to avoid costly regex calls + if (line.find("/mention)") != std::string::npos) + { + // restore original mention URL from [@username](URL) format + static const boost::regex altered_mention_regex("\\[@([^\\]]+)\\]\\((" APP_HEADER_REGEX "/agent/[\\da-f-]+/mention)\\)", + boost::regex::perl | boost::regex::icase); + + // $2 captures the URL part + line = boost::regex_replace(line, altered_mention_regex, "$2"); + } + //updated 1.23 plain text log format requires a space added before subsequent lines in a multilined message if (' ' == line[0]) { |