mirror of
https://github.com/jointakahe/takahe.git
synced 2025-02-02 17:32:19 +00:00
Allow incoming Posts with Bookwyrm Edition tags (#405)
This commit is contained in:
parent
fc8b5be4a0
commit
cb66b9559d
1 changed files with 9 additions and 3 deletions
|
@ -786,16 +786,22 @@ class Post(StatorModel):
|
||||||
# Mentions and hashtags
|
# Mentions and hashtags
|
||||||
post.hashtags = []
|
post.hashtags = []
|
||||||
for tag in get_list(data, "tag"):
|
for tag in get_list(data, "tag"):
|
||||||
if tag["type"].lower() == "mention":
|
tag_type = tag["type"].lower()
|
||||||
|
if tag_type == "mention":
|
||||||
mention_identity = Identity.by_actor_uri(tag["href"], create=True)
|
mention_identity = Identity.by_actor_uri(tag["href"], create=True)
|
||||||
post.mentions.add(mention_identity)
|
post.mentions.add(mention_identity)
|
||||||
elif tag["type"].lower() in ["_:hashtag", "hashtag"]:
|
elif tag_type in ["_:hashtag", "hashtag"]:
|
||||||
post.hashtags.append(
|
post.hashtags.append(
|
||||||
get_value_or_map(tag, "name", "nameMap").lower().lstrip("#")
|
get_value_or_map(tag, "name", "nameMap").lower().lstrip("#")
|
||||||
)
|
)
|
||||||
elif tag["type"].lower() in ["toot:emoji", "emoji"]:
|
elif tag_type in ["toot:emoji", "emoji"]:
|
||||||
emoji = Emoji.by_ap_tag(post.author.domain, tag, create=True)
|
emoji = Emoji.by_ap_tag(post.author.domain, tag, create=True)
|
||||||
post.emojis.add(emoji)
|
post.emojis.add(emoji)
|
||||||
|
elif tag_type == "edition":
|
||||||
|
# Bookwyrm Edition is similar to hashtags. There should be a link to
|
||||||
|
# the book in the Note's content and a post attachment of the cover
|
||||||
|
# image. No special processing should be needed for ingest.
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"Unknown tag type {tag['type']}")
|
raise ValueError(f"Unknown tag type {tag['type']}")
|
||||||
# Visibility and to
|
# Visibility and to
|
||||||
|
|
Loading…
Reference in a new issue