kopia lustrzana https://gitlab.com/jaywink/federation
Try matching against Hashtag objects href property in remove_tag_links.
rodzic
daa742124d
commit
db0b545f24
|
@ -821,10 +821,17 @@ class Note(Object, RawContentMixin):
|
|||
"""
|
||||
super().post_receive()
|
||||
|
||||
if getattr(self, 'target_id'): self.entity_type = 'Comment'
|
||||
if not self.raw_content or self._media_type == "text/markdown":
|
||||
# Skip when markdown
|
||||
return
|
||||
|
||||
hrefs = [tag.href.lower() for tag in self.tag_objects]
|
||||
# noinspection PyUnusedLocal
|
||||
def remove_tag_links(attrs, new=False):
|
||||
# Hashtag object hrefs
|
||||
href = (None, "href")
|
||||
if attrs.get(href, "").lower() in hrefs:
|
||||
return
|
||||
|
||||
# Mastodon
|
||||
rel = (None, "rel")
|
||||
|
@ -832,16 +839,11 @@ class Note(Object, RawContentMixin):
|
|||
return
|
||||
|
||||
# Friendica
|
||||
href = (None, "href")
|
||||
if attrs.get(href).endswith(f'tag={attrs.get("_text")}'):
|
||||
if attrs.get(href, "").endswith(f'tag={attrs.get("_text")}'):
|
||||
return
|
||||
|
||||
return attrs
|
||||
|
||||
if not self.raw_content or self._media_type == "text/markdown":
|
||||
# Skip when markdown
|
||||
return
|
||||
|
||||
self.raw_content = bleach.linkify(
|
||||
self.raw_content,
|
||||
callbacks=[remove_tag_links],
|
||||
|
@ -849,6 +851,8 @@ class Note(Object, RawContentMixin):
|
|||
skip_tags=["code", "pre"],
|
||||
)
|
||||
|
||||
if getattr(self, 'target_id'): self.entity_type = 'Comment'
|
||||
|
||||
def add_tag_objects(self) -> None:
|
||||
"""
|
||||
Populate tags to the object.tag list.
|
||||
|
|
Ładowanie…
Reference in New Issue