mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-24 11:51:27 -08:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
ac1d49a41d
3 changed files with 23 additions and 2 deletions
|
@ -1321,6 +1321,24 @@ def create_post_reply(activity_log: ActivityPubLog, community: Community, in_rep
|
||||||
activity_log.result = 'ignored'
|
activity_log.result = 'ignored'
|
||||||
return None
|
return None
|
||||||
post_id, parent_comment_id, root_id = find_reply_parent(in_reply_to)
|
post_id, parent_comment_id, root_id = find_reply_parent(in_reply_to)
|
||||||
|
|
||||||
|
# special case: add comment from auto-tldr bot to post body if body is empty
|
||||||
|
if post_id and not parent_comment_id and not root_id and user.ap_id == 'autotldr@lemmings.world':
|
||||||
|
post = Post.query.get(post_id)
|
||||||
|
if post and post.body_html == '':
|
||||||
|
if 'source' in request_json['object'] and isinstance(request_json['object']['source'], dict) and \
|
||||||
|
'mediaType' in request_json['object']['source'] and \
|
||||||
|
request_json['object']['source']['mediaType'] == 'text/markdown':
|
||||||
|
body = request_json['object']['source']['content']
|
||||||
|
# sometimes the bot includes its content inside spoiler tags, sometimes not. This is an attempt to make things look consistent.
|
||||||
|
if not '::: spoiler' in body:
|
||||||
|
post.body = "🤖 I'm a bot that provides automatic summaries for articles:\n::: spoiler Click here to see the summary\n" + body + '\n:::'
|
||||||
|
else:
|
||||||
|
post.body = body
|
||||||
|
post.body_html = markdown_to_html(post.body) + '<small><span class="render_username">Generated using AI by: <a href="/u/autotldr@lemmings.world" title="AutoTL;DR">AutoTL;DR</a></span></small>'
|
||||||
|
db.session.commit()
|
||||||
|
return None
|
||||||
|
|
||||||
if post_id or parent_comment_id or root_id:
|
if post_id or parent_comment_id or root_id:
|
||||||
# set depth to +1 of the parent depth
|
# set depth to +1 of the parent depth
|
||||||
if parent_comment_id:
|
if parent_comment_id:
|
||||||
|
|
|
@ -545,6 +545,9 @@ class Community(db.Model):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def loop_videos(self) -> bool:
|
||||||
|
return 'gifs' in self.name
|
||||||
|
|
||||||
def delete_dependencies(self):
|
def delete_dependencies(self):
|
||||||
for post in self.posts:
|
for post in self.posts:
|
||||||
post.delete_dependencies()
|
post.delete_dependencies()
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
<p><audio controls preload="{{ 'none' if low_bandwidth else 'metadata' }}" src="{{ post.url }}"></audio></p>
|
<p><audio controls preload="{{ 'none' if low_bandwidth else 'metadata' }}" src="{{ post.url }}"></audio></p>
|
||||||
{% elif post.url.endswith('.mp4') or post.url.endswith('.webm') %}
|
{% elif post.url.endswith('.mp4') or post.url.endswith('.webm') %}
|
||||||
<p>
|
<p>
|
||||||
<video class="responsive-video" controls preload="{{ 'metadata' if low_bandwidth else 'auto' }}">
|
<video class="responsive-video" controls preload="{{ 'metadata' if low_bandwidth else 'auto' }}" {{ 'loop' if post.community.loop_videos() }}>
|
||||||
{% if post.url.endswith('.mp4') %}
|
{% if post.url.endswith('.mp4') %}
|
||||||
<source src="{{ post.url }}" type="video/mp4" />
|
<source src="{{ post.url }}" type="video/mp4" />
|
||||||
{% elif post.url.endswith('.webm') %}
|
{% elif post.url.endswith('.webm') %}
|
||||||
|
@ -106,7 +106,7 @@
|
||||||
<span class="fe fe-external"></span></a></p>
|
<span class="fe fe-external"></span></a></p>
|
||||||
{% if post.url.endswith('.mp4') or post.url.endswith('.webm') %}
|
{% if post.url.endswith('.mp4') or post.url.endswith('.webm') %}
|
||||||
<p>
|
<p>
|
||||||
<video class="responsive-video" controls preload="{{ 'none' if low_bandwidth else 'auto' }}" {{ 'autoplay muted' if autoplay }}>
|
<video class="responsive-video" controls preload="{{ 'none' if low_bandwidth else 'auto' }}" {{ 'autoplay muted' if autoplay }} {{ 'loop' if post.community.loop_videos() }}>
|
||||||
{% if post.url.endswith('.mp4') %}
|
{% if post.url.endswith('.mp4') %}
|
||||||
<source src="{{ post.url }}" type="video/mp4" />
|
<source src="{{ post.url }}" type="video/mp4" />
|
||||||
{% elif post.url.endswith('.webm') %}
|
{% elif post.url.endswith('.webm') %}
|
||||||
|
|
Loading…
Add table
Reference in a new issue