Skip to content

Commit

Permalink
Fixed bob loading in muc
Browse files Browse the repository at this point in the history
  • Loading branch information
Ri0n committed Jun 18, 2024
1 parent 65b6801 commit d4497d9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
9 changes: 7 additions & 2 deletions src/chatview_webkit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,13 @@ class ChatViewJSObject : public ChatViewThemeSession {
std::function<void(bool success, const QByteArray &, const QByteArray &)> callback)
{
if (url.path().startsWith("/psibob/")) {
QString cid = url.path().mid(sizeof("/psibob/") - 1);
_view->d->account_->loadBob(_view->d->jid_, cid, this, callback);
QString cid = url.path().mid(sizeof("/psibob/") - 1);
auto sender = QUrlQuery(url).queryItemValue("sender", QUrl::FullyDecoded);
auto j = _view->d->jid_;
if (!sender.isEmpty()) {
j = j.withResource(sender);
}
_view->d->account_->loadBob(j, cid, this, callback);
return true;
}
// qDebug("Unhandled url: %s", qPrintable(url.toString()));
Expand Down
2 changes: 1 addition & 1 deletion themes/chatview/psi/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function psiThemeAdapter(chat) {
if (nextEl) {
chat.util.siblingHtml(nextEl, html);
} else {
chat.util.appendHtml(shared.chatElement, html);
chat.util.appendHtml(shared.chatElement, html, shared.isMuc? shared.cdata.sender : "");
}
shared.scroller.invalidate();
},
Expand Down
19 changes: 11 additions & 8 deletions themes/chatview/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,14 @@ function initPsiTheme() {
}
},

replaceBob : function(el) {
replaceBob : function(el, sender) {
var els = el.querySelectorAll("img"); // frozen list
for (var i=0; i < els.length; i++) {
if (els[i].src.indexOf('cid:') == 0) {
els[i].src = "/psibob/" + els[i].src.slice(4);
els[i].src = "psibob/" + els[i].src.slice(4);
if (sender) {
els[i].src += "?sender=" + encodeURIComponent(sender);
}
}
}
},
Expand Down Expand Up @@ -394,21 +397,21 @@ function initPsiTheme() {
}
},

prepareContents : function(html) {
prepareContents : function(html, sender) {
htmlSource.innerHTML = html;
chat.util.replaceBob(htmlSource);
chat.util.replaceBob(htmlSource, sender);
chat.util.handleLinks(htmlSource);
chat.util.replaceIcons(htmlSource);
chat.util.handleShares(htmlSource);
},

appendHtml : function(dest, html) {
chat.util.prepareContents(html);
appendHtml : function(dest, html, sender) {
chat.util.prepareContents(html, sender);
while (htmlSource.firstChild) dest.appendChild(htmlSource.firstChild);
},

siblingHtml : function(dest, html) {
chat.util.prepareContents(html);
siblingHtml : function(dest, html, sourceUser) {
chat.util.prepareContents(html, sourceUser);
while (htmlSource.firstChild) dest.parentNode.insertBefore(htmlSource.firstChild, dest);
},

Expand Down

0 comments on commit d4497d9

Please sign in to comment.