kopia lustrzana https://gitlab.com/jaywink/federation
Remove unreachable code. Improve (I hope) the mention regex for raw text.
rodzic
7d750d3365
commit
0783bf43aa
|
@ -874,21 +874,13 @@ class Note(Object, RawContentMixin):
|
||||||
|
|
||||||
def extract_mentions(self):
|
def extract_mentions(self):
|
||||||
"""
|
"""
|
||||||
Extract mentions from the inbound Mention objects.
|
Attempt to extract mentions from raw_content if available
|
||||||
|
|
||||||
Also attempt to extract from raw_content if available
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self.raw_content:
|
if self.raw_content:
|
||||||
super().extract_mentions()
|
super().extract_mentions()
|
||||||
return
|
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
|
@property
|
||||||
def rendered_content(self):
|
def rendered_content(self):
|
||||||
if self._soup: return str(self._soup)
|
if self._soup: return str(self._soup)
|
||||||
|
|
|
@ -10,8 +10,8 @@ from commonmark import commonmark
|
||||||
|
|
||||||
ILLEGAL_TAG_CHARS = "!#$%^&*+.,@£/()=?`'\\{[]}~;:\"’”—\xa0"
|
ILLEGAL_TAG_CHARS = "!#$%^&*+.,@£/()=?`'\\{[]}~;:\"’”—\xa0"
|
||||||
TAG_PATTERN = re.compile(r'(#[\w]+)', re.UNICODE)
|
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):
|
def decode_if_bytes(text):
|
||||||
try:
|
try:
|
||||||
|
|
Ładowanie…
Reference in New Issue