Switch to SQLAlchemy 2.0 query style

This commit is contained in:
Thomas Sileo 2022-06-29 08:56:39 +02:00
parent f4c70096e2
commit 18bd2cb664
8 changed files with 266 additions and 207 deletions

View file

@ -1,6 +1,7 @@
import re
from markdown import markdown
from sqlalchemy import select
from sqlalchemy.orm import Session
from app import models
@ -43,9 +44,9 @@ def _mentionify(
mentioned_actors = []
for mention in re.findall(_MENTION_REGEX, content):
_, username, domain = mention.split("@")
actor = (
db.query(models.Actor).filter(models.Actor.handle == mention).one_or_none()
)
actor = db.execute(
select(models.Actor).where(models.Actor.handle == mention)
).scalar_one_or_none()
if not actor:
actor_url = webfinger.get_actor_url(mention)
if not actor_url: