mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-12-22 05:04:27 +00:00
Tweak reply processing
This commit is contained in:
parent
9cbe608fc9
commit
ade3bee214
4 changed files with 10 additions and 6 deletions
|
@ -572,12 +572,13 @@ def task_process_reply() -> _Response:
|
|||
)
|
||||
|
||||
for new_reply in new_replies:
|
||||
if find_one_activity(by_object_id(new_reply.id)) or DB.replies.find_one(
|
||||
{"remote_id": root_reply}
|
||||
):
|
||||
if find_one_activity(
|
||||
{**by_object_id(new_reply.id), **by_type(ap.ActivityType.CREATE)}
|
||||
) or DB.replies.find_one(by_remote_id(new_reply.id)):
|
||||
continue
|
||||
|
||||
actor = new_reply.get_actor()
|
||||
# Save the reply with the cached actor and the thread flag/ID
|
||||
save_reply(
|
||||
new_reply,
|
||||
{
|
||||
|
|
|
@ -35,11 +35,11 @@ from core.meta import Box
|
|||
from core.meta import MetaKey
|
||||
from core.meta import by_object_id
|
||||
from core.meta import by_remote_id
|
||||
from core.meta import by_type
|
||||
from core.meta import flag
|
||||
from core.meta import inc
|
||||
from core.meta import upsert
|
||||
from core.tasks import Tasks
|
||||
from core.meta import by_type
|
||||
from utils import now
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
|
@ -35,7 +35,10 @@ def lookup(url: str) -> ap.BaseActivity:
|
|||
except requests.RequestException as err:
|
||||
raise RemoteServerUnavailableError(f"failed to GET {url}: {err!r}")
|
||||
|
||||
resp.raise_for_status()
|
||||
try:
|
||||
resp.raise_for_status()
|
||||
except Exception:
|
||||
return ap.fetch_remote_activity(url)
|
||||
|
||||
# If the page is HTML, maybe it contains an alternate link pointing to an AP object
|
||||
for alternate in mf2py.parse(resp.text).get("alternates", []):
|
||||
|
|
|
@ -69,7 +69,7 @@ def get_software_name(server: str) -> str:
|
|||
|
||||
return SoftwareName.UNKNOWN.value
|
||||
except requests.RequestException:
|
||||
pass
|
||||
return SoftwareName.UNKNOWN.value
|
||||
|
||||
if _try_mastodon_api(server):
|
||||
return SoftwareName.MASTODON.value
|
||||
|
|
Loading…
Reference in a new issue