mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 11:26:56 -08:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
4ba1b1aa4a
9 changed files with 27 additions and 11 deletions
|
@ -1030,7 +1030,7 @@ def process_inbox_request(request_json, store_ap_json):
|
|||
user_ap_id = request_json['object']['actor']
|
||||
user = find_actor_or_create(user_ap_id)
|
||||
if not user or not isinstance(user, User):
|
||||
log_incoming_ap(id, APLOG_ANNOUNCE, APLOG_FAILURE, request_json, 'Blocked or unfound user for Announce object actor ' + user_ap_id)
|
||||
log_incoming_ap(id, APLOG_ANNOUNCE, APLOG_FAILURE, request_json if store_ap_json else None, 'Blocked or unfound user for Announce object actor ' + user_ap_id)
|
||||
return
|
||||
|
||||
user.last_seen = site.last_active = utcnow()
|
||||
|
@ -1246,7 +1246,7 @@ def process_inbox_request(request_json, store_ap_json):
|
|||
|
||||
return
|
||||
|
||||
log_incoming_ap(id, APLOG_MONITOR, APLOG_PROCESSING, request_json if store_ap_json else None, 'Unmatched activity')
|
||||
log_incoming_ap(id, APLOG_MONITOR, APLOG_PROCESSING, request_json, 'Unmatched activity')
|
||||
|
||||
|
||||
@celery.task
|
||||
|
|
|
@ -1936,6 +1936,7 @@ def update_post_from_activity(post: Post, request_json: dict):
|
|||
else:
|
||||
post.type = POST_TYPE_ARTICLE
|
||||
post.url = ''
|
||||
post.image_id = None
|
||||
if post.cross_posts is not None: # unlikely, but not impossible
|
||||
old_cross_posts = Post.query.filter(Post.id.in_(post.cross_posts)).all()
|
||||
post.cross_posts.clear()
|
||||
|
|
|
@ -75,7 +75,6 @@ class EditCommunityForm(FlaskForm):
|
|||
local_only = BooleanField(_l('Only accept posts from current instance'))
|
||||
restricted_to_mods = BooleanField(_l('Only moderators can post'))
|
||||
new_mods_wanted = BooleanField(_l('New moderators wanted'))
|
||||
show_home = BooleanField(_l('Posts show on home page'))
|
||||
show_popular = BooleanField(_l('Posts can be popular'))
|
||||
show_all = BooleanField(_l('Posts show in All list'))
|
||||
low_quality = BooleanField(_l("Low quality / toxic - upvotes in here don't add to reputation"))
|
||||
|
|
|
@ -683,7 +683,6 @@ def admin_community_edit(community_id):
|
|||
community.local_only = form.local_only.data
|
||||
community.restricted_to_mods = form.restricted_to_mods.data
|
||||
community.new_mods_wanted = form.new_mods_wanted.data
|
||||
community.show_home = form.show_home.data
|
||||
community.show_popular = form.show_popular.data
|
||||
community.show_all = form.show_all.data
|
||||
community.low_quality = form.low_quality.data
|
||||
|
@ -740,7 +739,6 @@ def admin_community_edit(community_id):
|
|||
form.local_only.data = community.local_only
|
||||
form.new_mods_wanted.data = community.new_mods_wanted
|
||||
form.restricted_to_mods.data = community.restricted_to_mods
|
||||
form.show_home.data = community.show_home
|
||||
form.show_popular.data = community.show_popular
|
||||
form.show_all.data = community.show_all
|
||||
form.low_quality.data = community.low_quality
|
||||
|
|
|
@ -456,7 +456,7 @@ class Community(db.Model):
|
|||
private_mods = db.Column(db.Boolean, default=False)
|
||||
|
||||
# Which feeds posts from this community show up in
|
||||
show_home = db.Column(db.Boolean, default=False) # For anonymous users. When logged in, the home feed shows posts from subscribed communities
|
||||
show_home = db.Column(db.Boolean, default=False) # unused
|
||||
show_popular = db.Column(db.Boolean, default=True)
|
||||
show_all = db.Column(db.Boolean, default=True)
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ from wtforms import SelectField, RadioField
|
|||
|
||||
from app import db, constants, cache, celery
|
||||
from app.activitypub.signature import HttpSignature, post_request, default_context, post_request_in_background
|
||||
from app.activitypub.util import notify_about_post_reply, inform_followers_of_post_update
|
||||
from app.activitypub.util import notify_about_post_reply, inform_followers_of_post_update, update_post_from_activity
|
||||
from app.community.util import save_post, send_to_remote_instance
|
||||
from app.inoculation import inoculation
|
||||
from app.post.forms import NewReplyForm, ReportPostForm, MeaCulpaForm, CrossPostForm
|
||||
|
@ -32,7 +32,7 @@ from app.utils import get_setting, render_template, allowlist_html, markdown_to_
|
|||
blocked_instances, blocked_domains, community_moderators, blocked_phrases, show_ban_message, recently_upvoted_posts, \
|
||||
recently_downvoted_posts, recently_upvoted_post_replies, recently_downvoted_post_replies, reply_is_stupid, \
|
||||
languages_for_form, menu_topics, add_to_modlog, blocked_communities, piefed_markdown_to_lemmy_markdown, \
|
||||
permission_required, blocked_users
|
||||
permission_required, blocked_users, get_request
|
||||
|
||||
|
||||
def show_post(post_id: int):
|
||||
|
@ -1901,6 +1901,25 @@ def post_reply_view_voting_activity(comment_id: int):
|
|||
)
|
||||
|
||||
|
||||
@bp.route('/post/<int:post_id>/fixup_from_remote', methods=['GET'])
|
||||
@login_required
|
||||
@permission_required('change instance settings')
|
||||
def post_fixup_from_remote(post_id: int):
|
||||
post = Post.query.get_or_404(post_id)
|
||||
|
||||
# will fail for some MBIN objects for same reason that 'View original on ...' does
|
||||
# (ap_id is lowercase, but original URL was mixed-case and remote instance software is case-sensitive)
|
||||
remote_post_request = get_request(post.ap_id, headers={'Accept': 'application/activity+json'})
|
||||
if remote_post_request.status_code == 200:
|
||||
remote_post_json = remote_post_request.json()
|
||||
remote_post_request.close()
|
||||
if 'type' in remote_post_json and remote_post_json['type'] == 'Page':
|
||||
update_json = {'type': 'Update', 'object': remote_post_json}
|
||||
update_post_from_activity(post, update_json)
|
||||
|
||||
return redirect(url_for('activitypub.post_ap', post_id=post.id))
|
||||
|
||||
|
||||
@bp.route('/post/<int:post_id>/cross-post', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def post_cross_post(post_id: int):
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
<th># Posts</th>
|
||||
<th>Retention</th>
|
||||
<th>Layout</th>
|
||||
<th title="{{ _('Posts show on home page.') }}">Home</th>
|
||||
<th title="{{ _('Posts can be popular.') }}">Popular</th>
|
||||
<th title="{{ _('Posts show in the All feed.') }}">All</th>
|
||||
<th title="{{ _('Content warning, NSFW or NSFL set for community.') }}">Warning</th>
|
||||
|
@ -37,7 +36,6 @@
|
|||
<td>{{ community.post_count }}</td>
|
||||
<td>{{ community.content_retention if community.content_retention != -1 }}</td>
|
||||
<td>{{ community.default_layout if community.default_layout }}</td>
|
||||
<th>{{ '✓'|safe if community.show_home else '✗'|safe }}</th>
|
||||
<th>{{ '✓'|safe if community.show_popular else '✗'|safe }}</th>
|
||||
<th>{{ '✓'|safe if community.show_all else '✗'|safe }}</th>
|
||||
<th>{{ '⚠'|safe if community.nsfw or community.nsfl or community.content_warning else ''|safe }}</th>
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
{{ render_field(form.banned) }}
|
||||
{{ render_field(form.local_only) }}
|
||||
{{ render_field(form.new_mods_wanted) }}
|
||||
{{ render_field(form.show_home) }}
|
||||
{{ render_field(form.show_popular) }}
|
||||
{{ render_field(form.show_all) }}
|
||||
{{ render_field(form.low_quality) }}
|
||||
|
|
|
@ -71,6 +71,8 @@
|
|||
{% if current_user.is_authenticated and (current_user.is_admin() or current_user.is_staff()) -%}
|
||||
<li><a href="{{ url_for('post.post_view_voting_activity', post_id=post.id) }}" class="no-underline" rel="nofollow"><span class="fe fe-sticky-left"></span>
|
||||
{{ _('View Voting Activity') }}</a></li>
|
||||
<li><a href="{{ url_for('post.post_fixup_from_remote', post_id=post.id) }}" class="no-underline" rel="nofollow"><span class="fe fe-sticky-right"></span>
|
||||
{{ _('Fixup from remote') }}</a></li>
|
||||
{% endif -%}
|
||||
</ul>
|
||||
<p>{{ _('If you want to perform more than one of these (e.g. block and report), hold down Ctrl and click, then complete the operation in the new tabs that open.') }}</p>
|
||||
|
|
Loading…
Reference in a new issue