diff --git a/app/activitypub/routes.py b/app/activitypub/routes.py index 745de6cf..dd751e08 100644 --- a/app/activitypub/routes.py +++ b/app/activitypub/routes.py @@ -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 diff --git a/app/activitypub/util.py b/app/activitypub/util.py index a207b45b..745a1612 100644 --- a/app/activitypub/util.py +++ b/app/activitypub/util.py @@ -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() diff --git a/app/admin/forms.py b/app/admin/forms.py index d23943a8..8e7a1e75 100644 --- a/app/admin/forms.py +++ b/app/admin/forms.py @@ -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")) diff --git a/app/admin/routes.py b/app/admin/routes.py index 36497d22..973e52e9 100644 --- a/app/admin/routes.py +++ b/app/admin/routes.py @@ -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 diff --git a/app/models.py b/app/models.py index 14278d96..82cd2465 100644 --- a/app/models.py +++ b/app/models.py @@ -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) diff --git a/app/post/routes.py b/app/post/routes.py index 2609c5de..d872e062 100644 --- a/app/post/routes.py +++ b/app/post/routes.py @@ -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//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//cross-post', methods=['GET', 'POST']) @login_required def post_cross_post(post_id: int): diff --git a/app/templates/admin/communities.html b/app/templates/admin/communities.html index eb70f955..d90f1f00 100644 --- a/app/templates/admin/communities.html +++ b/app/templates/admin/communities.html @@ -23,7 +23,6 @@ # Posts Retention Layout - Home Popular All Warning @@ -37,7 +36,6 @@ {{ community.post_count }} {{ community.content_retention if community.content_retention != -1 }} {{ community.default_layout if community.default_layout }} - {{ '✓'|safe if community.show_home else '✗'|safe }} {{ '✓'|safe if community.show_popular else '✗'|safe }} {{ '✓'|safe if community.show_all else '✗'|safe }} {{ '⚠'|safe if community.nsfw or community.nsfl or community.content_warning else ''|safe }} diff --git a/app/templates/admin/edit_community.html b/app/templates/admin/edit_community.html index 297a04b1..a1ce4b71 100644 --- a/app/templates/admin/edit_community.html +++ b/app/templates/admin/edit_community.html @@ -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) }} diff --git a/app/templates/post/post_options.html b/app/templates/post/post_options.html index 7c4a41eb..18f21070 100644 --- a/app/templates/post/post_options.html +++ b/app/templates/post/post_options.html @@ -71,6 +71,8 @@ {% if current_user.is_authenticated and (current_user.is_admin() or current_user.is_staff()) -%}
  • {{ _('View Voting Activity') }}
  • +
  • + {{ _('Fixup from remote') }}
  • {% endif -%}

    {{ _('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.') }}