generalise fallback for glitch-soc notifications

This commit is contained in:
Vipra 2023-07-13 18:33:37 +02:00
parent 87906f2772
commit 3b779be8c8
2 changed files with 11 additions and 12 deletions

View file

@ -318,11 +318,7 @@ async function addProplate(element) {
// This allows us to pass incomplete nodes into this method, because
// we only process them after we have all required information.
let tempType = "status";
if (location.href.endsWith("notifications")) tempType = "notification";
generateProPlate(statusId, accountName, nametagEl, tempType);
generateProPlate(statusId, accountName, nametagEl, "status");
}
async function addToNotification(element) {
@ -337,7 +333,7 @@ async function addProplate(element) {
let nametagEl = accountNameEl;
element.setAttribute("protoots-checked", "true");
generateProPlate(statusId, accountName, nametagEl, "notification"); //FIXME: change back to notification when done testing
generateProPlate(statusId, accountName, nametagEl, "notification");
}
async function addToAccount(element) {
@ -350,11 +346,7 @@ async function addProplate(element) {
element.setAttribute("protoots-checked", "true");
let tempType = "account";
if (location.href.endsWith("notifications")) tempType = "notification";
generateProPlate(statusId, accountName, nametagEl, tempType);
generateProPlate(statusId, accountName, nametagEl, "account");
}
async function addToConversation(element) {

View file

@ -1,4 +1,4 @@
import { debug, error, info, warn } from "./logging";
import { debug, error, info, log, warn } from "./logging";
import { cachePronouns, getPronouns } from "./caching";
import { normaliseAccountName } from "./protootshelpers";
@ -60,6 +60,9 @@ export async function fetchPronouns(dataID, accountName, type) {
status = await fetchStatus(dataID);
}
log(`Fetching ${type} failed, trying notification instead.`);
if (!status) status = await fetchNotification(dataID); //fallback for glitch-soc notifications
const PronounField = getPronounField(status, accountName);
if (PronounField == "null") {
//TODO: if no field check bio
@ -86,6 +89,8 @@ async function fetchStatus(statusID) {
let status = await response.json();
if (!response.ok) return null;
//if status contains a reblog get that for further processing - we want the embedded post's author
if (status.reblog) status = status.reblog;
return status;
@ -128,6 +133,8 @@ async function fetchAccount(accountID) {
},
);
if (!response.ok) return null;
const account = await response.json();
return { account: account };