mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-23 14:13:21 +01:00
More logic to prevent recursive/wrong quote posts
This commit is contained in:
parent
e35e02593a
commit
2b6beee875
1 changed files with 16 additions and 8 deletions
|
@ -83,15 +83,23 @@ function _unfurlMastodonLink(instance, url) {
|
||||||
limit: 1,
|
limit: 1,
|
||||||
})
|
})
|
||||||
.then((results) => {
|
.then((results) => {
|
||||||
if (results.statuses.length > 0) {
|
const { statuses } = results;
|
||||||
const status = results.statuses[0];
|
if (statuses.length > 0) {
|
||||||
return {
|
// Filter out statuses that has content that contains the URL, in-case-sensitive
|
||||||
status,
|
const theStatuses = statuses.filter(
|
||||||
instance,
|
(status) =>
|
||||||
};
|
!status.content?.toLowerCase().includes(theURL.toLowerCase()),
|
||||||
} else {
|
);
|
||||||
throw new Error('No results');
|
|
||||||
|
if (theStatuses.length === 1) {
|
||||||
|
return {
|
||||||
|
status: theStatuses[0],
|
||||||
|
instance,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// If there are multiple statuses, give up, something is wrong
|
||||||
}
|
}
|
||||||
|
throw new Error('No results');
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleFulfill(result) {
|
function handleFulfill(result) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue