aboutsummaryrefslogtreecommitdiff
path: root/src/main/assets
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/assets')
-rw-r--r--src/main/assets/scripts.js27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/main/assets/scripts.js b/src/main/assets/scripts.js
index 87fdf7a4..00d7d616 100644
--- a/src/main/assets/scripts.js
+++ b/src/main/assets/scripts.js
@@ -517,15 +517,20 @@ function addTag(tag) {
var users = {};
+/**
+ * Fetch ActivityPub user profile info
+ *
+ * @param {string} dataUri user URI
+ * @param {*} callback callback
+ */
function fetchUserUri(dataUri, callback) {
if (users[dataUri]) {
callback(users[dataUri]);
} else {
- let data = new FormData();
- data.append('uri', dataUri);
- fetch('/u/', {
- method: 'POST',
- body: data
+ fetch(dataUri, {
+ headers: {
+ 'Accept': 'application/ld+json'
+ }
}).then(handleErrors)
.then(response => {
return response.json();
@@ -736,15 +741,15 @@ ready(() => {
setTimeout(() => fetchUserUri(dataUri, user => {
let header = el.closest('.msg-header');
Array.from(header.querySelectorAll('.a-username')).forEach(a => {
- a.setAttribute('href', user.uri);
+ a.setAttribute('href', dataUri);
let img = a.querySelector('img');
- if (img && user.avatar) {
- img.setAttribute('src', user.avatar);
- img.setAttribute('alt', user.uname);
+ if (img && user.icon) {
+ img.setAttribute('src', user.icon.url);
+ img.setAttribute('alt', user.preferredUsername);
}
let textNode = a.childNodes[0];
if (textNode.nodeType === Node.TEXT_NODE && textNode.nodeValue.trim().length > 0) {
- let uname = document.createTextNode(user.uname);
+ let uname = document.createTextNode(user.preferredUsername);
a.replaceChild(uname, a.firstChild);
}
});
@@ -757,7 +762,7 @@ ready(() => {
setTimeout(() => fetchUserUri(dataUri, user => {
let textNode = el.childNodes[0];
if (textNode.nodeType === Node.TEXT_NODE && textNode.nodeValue.trim().length > 0) {
- let uname = document.createTextNode(`@${user.uname}`);
+ let uname = document.createTextNode(`@${user.preferredUsername}`);
el.replaceChild(uname, el.firstChild);
}
}), 100);