federails-moderation 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +18 -0
- data/app/models/federails/moderation/report.rb +8 -0
- data/lib/federails/moderation/configuration.rb +11 -0
- data/lib/federails/moderation/version.rb +1 -1
- data/lib/federails/moderation.rb +8 -0
- metadata +18 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c01ff065ee20d0c97dd18a1385cee59dd07550fa284e6faa8a56f02c4693baf5
|
4
|
+
data.tar.gz: 2d9e9502fdf3bb8e754d5302016433fc76918975fc3bf789eb9e2615cb9a3f25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5d38544c27a78b2d08c112235b7fa093c5d7d8939b79e46f222ba997ebef5610abf5bab007a07e3c6e1a9c66047f964e0921ae5c16fdca00c0d6d88e95b13fa
|
7
|
+
data.tar.gz: 9ee81f14a7b28248766512c122488eede878701f7869abcb2c287c5ac7c2d26e12e04a231d5439dc8f5c372e6088fd4ddb03ba2ed3bc4952afd6c2e6536ce0a3
|
data/README.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Federails::Moderation
|
2
2
|
|
3
|
+
|
4
|
+

|
5
|
+
[](https://codeclimate.com/github/manyfold3d/federails-moderation/maintainability)
|
6
|
+
[](https://codeclimate.com/github/manyfold3d/federails-moderation/test_coverage)
|
7
|
+

|
8
|
+
|
9
|
+

|
10
|
+

|
11
|
+

|
12
|
+
|
3
13
|
A gem that provides moderation capabilities for [Federails](https://gitlab.com/experimentslabs/federails). It adds the following features:
|
4
14
|
|
5
15
|
* Handle incoming `Flag` activities, normally used for reporting content to moderators
|
@@ -50,6 +60,14 @@ r.ignore!
|
|
50
60
|
|
51
61
|
```
|
52
62
|
|
63
|
+
You can receive a callback in your application when a new report is received, by providing a proc which will be called:
|
64
|
+
|
65
|
+
```
|
66
|
+
Federails::Moderation.configure do |conf|
|
67
|
+
conf.after_report_created = ->(report) { MyApp::MyReportHandler.call(report) }
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
53
71
|
### Domain Blocks
|
54
72
|
|
55
73
|
You can block domains that are abusive like so:
|
@@ -2,6 +2,8 @@ class Federails::Moderation::Report < ApplicationRecord
|
|
2
2
|
belongs_to :federails_actor, class_name: "Federails::Actor", optional: true
|
3
3
|
belongs_to :object, polymorphic: true, optional: true
|
4
4
|
|
5
|
+
after_create :execute_create_callback
|
6
|
+
|
5
7
|
def resolve!
|
6
8
|
update!(resolved_at: DateTime.now, resolution: "resolved")
|
7
9
|
end
|
@@ -21,4 +23,10 @@ class Federails::Moderation::Report < ApplicationRecord
|
|
21
23
|
def local?
|
22
24
|
federails_actor&.local?
|
23
25
|
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def execute_create_callback
|
30
|
+
Federails::Moderation::Configuration.after_report_created&.call self
|
31
|
+
end
|
24
32
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Federails::Moderation
|
2
|
+
# rubocop:disable Style/ClassVars
|
3
|
+
|
4
|
+
# Stores the Federails::Moderation configuration in a _singleton_.
|
5
|
+
module Configuration
|
6
|
+
# A proc that is called any time new report is created
|
7
|
+
# Useful for sending notifications
|
8
|
+
mattr_accessor :after_report_created
|
9
|
+
end
|
10
|
+
# rubocop:enable Style/ClassVars
|
11
|
+
end
|
data/lib/federails/moderation.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
require "federails/moderation/version"
|
2
2
|
require "federails/moderation/engine"
|
3
|
+
require "federails/moderation/configuration"
|
3
4
|
|
4
5
|
module Federails
|
5
6
|
module Moderation
|
7
|
+
mattr_reader :configuration
|
8
|
+
@@configuration = Configuration
|
9
|
+
|
10
|
+
def self.configure
|
11
|
+
yield @@configuration
|
12
|
+
end
|
13
|
+
|
6
14
|
def self.table_name_prefix
|
7
15
|
"federails_moderation_"
|
8
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: federails-moderation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Smith
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-03-26 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rails
|
@@ -52,6 +51,20 @@ dependencies:
|
|
52
51
|
- - "~>"
|
53
52
|
- !ruby/object:Gem::Version
|
54
53
|
version: '6.0'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: simplecov
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0.22'
|
61
|
+
type: :development
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0.22'
|
55
68
|
description: Moderation additions for Federails; reporting, limit/suspend, server
|
56
69
|
blocking, etc
|
57
70
|
email:
|
@@ -73,6 +86,7 @@ files:
|
|
73
86
|
- db/migrate/20241127105043_create_federails_moderation_reports.rb
|
74
87
|
- db/migrate/20241128115659_create_federails_moderation_domain_blocks.rb
|
75
88
|
- lib/federails/moderation.rb
|
89
|
+
- lib/federails/moderation/configuration.rb
|
76
90
|
- lib/federails/moderation/engine.rb
|
77
91
|
- lib/federails/moderation/filtered_inbox.rb
|
78
92
|
- lib/federails/moderation/filtered_notifier.rb
|
@@ -86,7 +100,6 @@ metadata:
|
|
86
100
|
homepage_uri: https://github.com/manyfold3d/federails-moderation
|
87
101
|
source_code_uri: https://github.com/manyfold3d/federails-moderation
|
88
102
|
changelog_uri: https://github.com/manyfold3d/federails-moderation/releases
|
89
|
-
post_install_message:
|
90
103
|
rdoc_options: []
|
91
104
|
require_paths:
|
92
105
|
- lib
|
@@ -101,8 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
114
|
- !ruby/object:Gem::Version
|
102
115
|
version: '0'
|
103
116
|
requirements: []
|
104
|
-
rubygems_version: 3.
|
105
|
-
signing_key:
|
117
|
+
rubygems_version: 3.6.2
|
106
118
|
specification_version: 4
|
107
119
|
summary: Moderation additions for Federails.
|
108
120
|
test_files: []
|