More logic to prevent recursive/wrong quote posts

This commit is contained in:
Lim Chee Aun 2024-03-31 20:35:24 +08:00
parent e35e02593a
commit 2b6beee875

View file

@ -83,15 +83,23 @@ function _unfurlMastodonLink(instance, url) {
limit: 1,
})
.then((results) => {
if (results.statuses.length > 0) {
const status = results.statuses[0];
const { statuses } = results;
if (statuses.length > 0) {
// Filter out statuses that has content that contains the URL, in-case-sensitive
const theStatuses = statuses.filter(
(status) =>
!status.content?.toLowerCase().includes(theURL.toLowerCase()),
);
if (theStatuses.length === 1) {
return {
status,
status: theStatuses[0],
instance,
};
} else {
throw new Error('No results');
}
// If there are multiple statuses, give up, something is wrong
}
throw new Error('No results');
});
function handleFulfill(result) {