mirror of
https://github.com/zulip/zulip.git
synced 2025-11-21 23:19:10 +00:00
Pre-fetch data from the DB and hand to markdown thread
We want to avoid opening a DB connection in the markdown thread as its DB connection might live for a long time (imported from commit 7700b2ca793ee5e9add7f071b92f22a4bf576b3d)
This commit is contained in:
@@ -9,16 +9,5 @@ find_mentions = r'(?<![^\s\'\"\(,:<])@(?:\*\*([^\*]+)\*\*|(\w+))'
|
||||
|
||||
wildcards = ['all', 'everyone']
|
||||
|
||||
def find_user_for_mention(mention, realm):
|
||||
if mention in wildcards:
|
||||
return (True, None)
|
||||
|
||||
try:
|
||||
user = zerver.models.UserProfile.objects.filter(
|
||||
Q(full_name__iexact=mention) | Q(short_name__iexact=mention),
|
||||
is_active=True,
|
||||
realm=realm).order_by("id")[0]
|
||||
except IndexError:
|
||||
user = None
|
||||
|
||||
return (False, user)
|
||||
def user_mention_matches_wildcard(mention):
|
||||
return mention in wildcards
|
||||
|
||||
Reference in New Issue
Block a user