diff --git a/app/chat/routes.py b/app/chat/routes.py index f859c236..f5185b7a 100644 --- a/app/chat/routes.py +++ b/app/chat/routes.py @@ -145,7 +145,7 @@ def chat_report(conversation_id): if form.validate_on_submit(): report = Report(reasons=form.reasons_to_string(form.reasons.data), description=form.description.data, - type=4, reporter_id=current_user.id, suspect_conversation_id=conversation_id) + type=4, reporter_id=current_user.id, suspect_conversation_id=conversation_id, source_instance_id=1) db.session.add(report) # Notify site admin diff --git a/app/community/routes.py b/app/community/routes.py index ff04d57a..5ebc165a 100644 --- a/app/community/routes.py +++ b/app/community/routes.py @@ -578,7 +578,7 @@ def community_report(community_id: int): form = ReportCommunityForm() if form.validate_on_submit(): report = Report(reasons=form.reasons_to_string(form.reasons.data), description=form.description.data, - type=1, reporter_id=current_user.id, suspect_community_id=community.id) + type=1, reporter_id=current_user.id, suspect_community_id=community.id, source_instance_id=1) db.session.add(report) # Notify admin @@ -924,13 +924,13 @@ def community_moderate(actor): reports = Report.query.filter_by(status=0, in_community_id=community.id) if local_remote == 'local': - reports = reports.filter_by(ap_id=None) + reports = reports.filter(Report.source_instance_id == 1) if local_remote == 'remote': - reports = reports.filter(Report.ap_id != None) - reports = reports.order_by(desc(Report.created_at)).paginate(page=page, per_page=1000, error_out=False) + reports = reports.filter(Report.source_instance_id != 1) + reports = reports.filter(Report.status >= 0).order_by(desc(Report.created_at)).paginate(page=page, per_page=1000, error_out=False) - next_url = url_for('admin.admin_reports', page=reports.next_num) if reports.has_next else None - prev_url = url_for('admin.admin_reports', page=reports.prev_num) if reports.has_prev and page != 1 else None + next_url = url_for('community.community_moderate', page=reports.next_num) if reports.has_next else None + prev_url = url_for('community.community_moderate', page=reports.prev_num) if reports.has_prev and page != 1 else None return render_template('community/community_moderate.html', title=_('Moderation of %(community)s', community=community.display_name()), community=community, reports=reports, current='reports', diff --git a/app/constants.py b/app/constants.py index 97001e31..a6e64f05 100644 --- a/app/constants.py +++ b/app/constants.py @@ -16,4 +16,10 @@ SUBSCRIPTION_NONMEMBER = 0 SUBSCRIPTION_PENDING = -1 SUBSCRIPTION_BANNED = -2 -THREAD_CUTOFF_DEPTH = 4 \ No newline at end of file +THREAD_CUTOFF_DEPTH = 4 + +REPORT_STATE_NEW = 0 +REPORT_STATE_ESCALATED = 1 +REPORT_STATE_APPEALED = 2 +REPORT_STATE_RESOLVED = 3 +REPORT_STATE_DISCARDED = -1 diff --git a/app/models.py b/app/models.py index f7c5df44..3ccb3022 100644 --- a/app/models.py +++ b/app/models.py @@ -1193,7 +1193,7 @@ class Report(db.Model): id = db.Column(db.Integer, primary_key=True) reasons = db.Column(db.String(256)) description = db.Column(db.String(256)) - status = db.Column(db.Integer, default=0) + status = db.Column(db.Integer, default=0) # 0 = new, 1 = escalated to admin, 2 = being appealed, 3 = resolved, 4 = discarded type = db.Column(db.Integer, default=0) # 0 = user, 1 = post, 2 = reply, 3 = community, 4 = conversation reporter_id = db.Column(db.Integer, db.ForeignKey('user.id')) suspect_community_id = db.Column(db.Integer, db.ForeignKey('community.id')) @@ -1202,6 +1202,7 @@ class Report(db.Model): suspect_post_reply_id = db.Column(db.Integer, db.ForeignKey('post_reply.id')) suspect_conversation_id = db.Column(db.Integer, db.ForeignKey('conversation.id')) in_community_id = db.Column(db.Integer, db.ForeignKey('community.id')) + source_instance_id = db.Column(db.Integer, db.ForeignKey('instance.id')) # the instance of the reporter. mostly used to distinguish between local (instance 1) and remote reports created_at = db.Column(db.DateTime, default=utcnow) updated = db.Column(db.DateTime, default=utcnow) @@ -1214,7 +1215,7 @@ class Report(db.Model): return types[self.type] def is_local(self): - return True + return self.source_instance == 1 class IpBan(db.Model): diff --git a/app/post/routes.py b/app/post/routes.py index 79a5e4d3..cc9becb0 100644 --- a/app/post/routes.py +++ b/app/post/routes.py @@ -848,7 +848,7 @@ def post_report(post_id: int): if form.validate_on_submit(): report = Report(reasons=form.reasons_to_string(form.reasons.data), description=form.description.data, type=1, reporter_id=current_user.id, suspect_user_id=post.author.id, suspect_post_id=post.id, - suspect_community_id=post.community.id, in_community_id=post.community.id) + suspect_community_id=post.community.id, in_community_id=post.community.id, source_instance_id=1) db.session.add(report) # Notify moderators @@ -952,7 +952,8 @@ def post_reply_report(post_id: int, comment_id: int): if form.validate_on_submit(): report = Report(reasons=form.reasons_to_string(form.reasons.data), description=form.description.data, type=2, reporter_id=current_user.id, suspect_post_id=post.id, suspect_community_id=post.community.id, - suspect_user_id=post_reply.author.id, suspect_post_reply_id=post_reply.id) + suspect_user_id=post_reply.author.id, suspect_post_reply_id=post_reply.id, in_community_id=post.community.id, + source_instance_id=1) db.session.add(report) # Notify moderators diff --git a/app/templates/community/community_moderate.html b/app/templates/community/community_moderate.html index 38bcf75c..df481696 100644 --- a/app/templates/community/community_moderate.html +++ b/app/templates/community/community_moderate.html @@ -57,8 +57,6 @@ View {% elif report.suspect_user_id %} View - {% elif report.suspect_community_id %} - View {% endif %} diff --git a/app/templates/post/add_reply.html b/app/templates/post/add_reply.html index 7a7e9d7e..75120dcd 100644 --- a/app/templates/post/add_reply.html +++ b/app/templates/post/add_reply.html @@ -82,8 +82,15 @@