Remove unreachable code. Improve (I hope) the mention regex for raw text.

ap-processing-improvements
Alain St-Denis 2023-07-15 09:54:41 -04:00
rodzic 7d750d3365
commit 0783bf43aa
2 zmienionych plików z 3 dodań i 11 usunięć

Wyświetl plik

@ -874,21 +874,13 @@ class Note(Object, RawContentMixin):
def extract_mentions(self):
"""
Extract mentions from the inbound Mention objects.
Also attempt to extract from raw_content if available
Attempt to extract mentions from raw_content if available
"""
if self.raw_content:
super().extract_mentions()
return
for mention in self.tag_objects:
if isinstance(mention, Mention):
profile = get_profile_or_entity(fid=mention.href)
handle = getattr(profile, 'finger', None)
if handle: self._mentions.add(handle)
@property
def rendered_content(self):
if self._soup: return str(self._soup)

Wyświetl plik

@ -10,8 +10,8 @@ from commonmark import commonmark
ILLEGAL_TAG_CHARS = "!#$%^&*+.,@£/()=?`'\\{[]}~;:\"’”—\xa0"
TAG_PATTERN = re.compile(r'(#[\w]+)', re.UNICODE)
MENTION_PATTERN = re.compile(r'(@{?[\S ]?[^{}@]+[@;]?\s*[\w\-./@]+[\w/]+}?)', re.UNICODE)
# This will match non matching braces. I don't think it's an issue.
MENTION_PATTERN = re.compile(r'(@\{?(?:[\w\-. \u263a-\U0001f645]*; *)?[\w]+@[\w\-.]+\.[\w]+}?)', re.UNICODE)
def decode_if_bytes(text):
try: