This commit is contained in:
Doug Hoyte
2024-12-15 23:56:00 -05:00
parent af7056e50c
commit fe5a081c37
2 changed files with 14 additions and 2 deletions

View File

@ -241,7 +241,7 @@ struct Event {
// FIXME: Don't truncate UTF-8 mid-sequence
// FIXME: Don't put ellipsis if truncated text ends in punctuation
std::string summaryHtml() const {
std::string summaryHtml(bool withLink = true) const {
std::string content = json.at("content").get_string();
auto firstUrl = stripUrls(content);
@ -252,7 +252,7 @@ struct Event {
textAbbrev(content, 100);
templarInternal::htmlEscape(content, true);
if (firstUrl.size()) {
if (withLink && firstUrl.size()) {
while (content.size() && isspace(content.back())) content.pop_back();
if (content.empty()) {
content = firstUrl;
@ -513,6 +513,17 @@ struct EventThread {
}
std::string getSummary() {
if (!rootEventId.size()) return "";
auto p = eventCache.find(rootEventId);
if (p == eventCache.end()) return "";
const auto &elem = p->second;
return elem.summaryHtml(false);
}
TemplarResult render(lmdb::txn &txn, Decompressor &decomp, UserCache &userCache, std::optional<std::string> focusOnPubkey = std::nullopt) {
auto now = hoytech::curr_time_s();
flat_hash_set<uint64_t> processedLevIds;

View File

@ -178,6 +178,7 @@ HTTPResponse WebServer::generateReadResponse(lmdb::txn &txn, Decompressor &decom
if (u.path.size() == 2) {
EventThread et(txn, decomp, decodeBech32Simple(u.path[1]));
body = et.render(txn, decomp, userCache);
title = et.getSummary();
} else if (u.path.size() == 3) {
if (u.path[2] == "reply") {
auto ev = Event::fromIdExternal(txn, u.path[1]);