Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
276
Issues
276
List
Boards
Labels
Service Desk
Milestones
Merge Requests
46
Merge Requests
46
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
63ea0f30
Commit
63ea0f30
authored
17 minutes ago
by
Ben Hayward
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated to include subtree
parent
c4809d98
fix/report-reason-email-765
1 merge request
!328
WIP: [Sprint/NuancedNumbat](fix): Ban email now returning string of ban reason rather than index.
Pipeline
#90333077
failed with stages
in 14 minutes and 49 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
35 deletions
+92
-35
Core/Reports/Events.php
Core/Reports/Events.php
+13
-6
Spec/Core/Reports/EventsSpec.php
Spec/Core/Reports/EventsSpec.php
+44
-15
settings.example.php
settings.example.php
+35
-14
No files found.
Core/Reports/Events.php
View file @
63ea0f30
...
...
@@ -54,10 +54,10 @@ class Events
/**
* Returns a readable format for a given ban reason, converting
* tree indic
ies to their text counterparts, discarding sub-reason
.
* tree indic
es to their text counterparts
.
*
* e.g. with the default config, an index of
1 returns "is i
llegal"
* an index of 1.
1 also returns "is illegal
"
* e.g. with the default config, an index of
3 returns "I
llegal"
* an index of 1.
3 returns "Illegal (Extortion)
"
*
* @param string $index - the given ban reason index
* @return string the first reason in the ban reason tree, or
...
...
@@ -65,9 +65,16 @@ class Events
*/
public
function
getBanReasons
(
$reason
)
{
$reason
=
preg_split
(
"/\./"
,
$reason
)[
0
];
if
(
is_numeric
(
$reason
))
{
return
$this
->
config
->
get
(
'ban_reasons'
)[
$reason
];
$banReasons
=
$this
->
config
->
get
(
'ban_reasons'
);
$splitReason
=
preg_split
(
"/\./"
,
$reason
);
if
(
is_numeric
(
$reason
)
&&
isset
(
$splitReason
[
1
]))
{
$index
=
$splitReason
[
0
];
$subIndex
=
$splitReason
[
1
];
return
$banReasons
[
$index
][
'label'
]
.
$banReasons
[
$index
][
'reasons'
][
$subIndex
];
}
if
(
is_numeric
(
$reason
)
&&
isset
(
$splitReason
[
0
]))
{
return
$banReasons
[
$splitReason
[
0
]][
'label'
];
}
return
$reason
;
}
...
...
This diff is collapsed.
Click to expand it.
Spec/Core/Reports/EventsSpec.php
View file @
63ea0f30
...
...
@@ -14,6 +14,7 @@ class EventsSpec extends ObjectBehavior
/** @var EventsDispatcher */
protected
$dispatcher
;
protected
$config
;
protected
$banReasons
;
public
function
let
(
EventsDispatcher
$dispatcher
,
Config
$config
)
{
...
...
@@ -22,6 +23,43 @@ class EventsSpec extends ObjectBehavior
});
$this
->
dispatcher
=
$dispatcher
;
$this
->
config
=
$config
;
$this
->
banReasons
=
[
1
=>
[
'label'
=>
'Illegal '
,
'reasons'
=>
[
1
=>
'(Terrorism)'
,
2
=>
'(Paedophilia)'
,
3
=>
'(Extortion)'
,
4
=>
'(Fraud)'
,
5
=>
'(Revenge porn)'
,
6
=>
'(Sex trafficking)'
],
],
2
=>
[
'label'
=>
'Should be marked as explicit '
,
'reasons'
=>
[
1
=>
'for nudity'
,
2
=>
'for pornography'
,
3
=>
'for profanity'
,
4
=>
'for violence and gore'
,
5
=>
'for race, religion or gender'
,
]
],
3
=>
[
'label'
=>
'Encourages or incites violence'
],
4
=>
[
'label'
=>
'Harassment'
],
5
=>
[
'label'
=>
'Contains personal and confidential info'
],
6
=>
[
'label'
=>
'Maliciously targets users (@name, links, images or videos)'
],
7
=>
[
'label'
=>
'Impersonates someone in a misleading or deceptive manner'
],
8
=>
[
'label'
=>
'Is spam'
],
9
=>
[
'label'
=>
''
],
10
=>
[
'label'
=>
'Copyright infringement'
],
11
=>
[
'label'
=>
'Another reason'
],
12
=>
[
'label'
=>
'Incorrect use of hashtags'
],
13
=>
[
'label'
=>
'Malware'
],
14
=>
[
'label'
=>
''
],
15
=>
[
'label'
=>
'Trademark infringement'
],
16
=>
[
'label'
=>
'Token manipulation'
],
];
}
public
function
it_is_initializable
()
...
...
@@ -40,26 +78,17 @@ class EventsSpec extends ObjectBehavior
public
function
it_should_discern_ban_reason_text
()
{
$reasons
=
[
1
=>
'is illegal'
,
2
=>
'Should be marked as explicit'
,
3
=>
'Encourages or incites violence'
,
];
Di
::
_
()
->
get
(
'Config'
)
->
set
(
'ban_reasons'
,
$reasons
);
Di
::
_
()
->
get
(
'Config'
)
->
set
(
'ban_reasons'
,
$this
->
banReasons
);
$this
->
getBanReasons
(
1
)
->
shouldReturn
(
"
is illegal
"
);
->
shouldReturn
(
"
Illegal
"
);
$this
->
getBanReasons
(
"1.
1
"
)
->
shouldReturn
(
"
is illegal
"
);
$this
->
getBanReasons
(
"1.
3
"
)
->
shouldReturn
(
"
Illegal (Extortion)
"
);
$this
->
getBanReasons
(
"2.
9.9.9.9.9..9
"
)
->
shouldReturn
(
"Should be marked as explicit"
);
$this
->
getBanReasons
(
"2.
3
"
)
->
shouldReturn
(
"Should be marked as explicit
for profanity
"
);
$this
->
getBanReasons
(
"3.14159265359"
)
->
shouldReturn
(
"Encourages or incites violence"
);
$this
->
getBanReasons
(
"3"
)
->
shouldReturn
(
"Encourages or incites violence"
);
...
...
This diff is collapsed.
Click to expand it.
settings.example.php
View file @
63ea0f30
...
...
@@ -581,18 +581,39 @@ $CONFIG->set('pro', [
]);
$CONFIG
->
set
(
'ban_reasons'
,
[
1
=>
'is illegal'
,
2
=>
'Should be marked as explicit'
,
3
=>
'Encourages or incites violence'
,
4
=>
'Harassment'
,
5
=>
'contains personal and confidential info'
,
6
=>
'Maliciously targets users (@name, links, images or videos)'
,
7
=>
'Impersonates someone in a misleading or deceptive manner'
,
8
=>
'is spam'
,
10
=>
'is a copyright infringement'
,
11
=>
'Another reason'
,
12
=>
'Incorrect use of hashtags'
,
13
=>
'Malware'
,
15
=>
'Trademark infringement'
,
16
=>
'Token manipulation'
1
=>
[
'label'
=>
'Illegal'
,
'reasons'
=>
[
1
=>
'(Terrorism)'
,
2
=>
'(Paedophilia)'
,
3
=>
'(Extortion)'
,
4
=>
'(Fraud)'
,
5
=>
'(Revenge porn)'
,
6
=>
'(Sex trafficking)'
],
],
2
=>
[
'label'
=>
'Should be marked as explicit'
,
'reasons'
=>
[
1
=>
'for nudity'
,
2
=>
'for pornography'
,
3
=>
'for profanity'
,
4
=>
'for violence and gore'
,
5
=>
'for race, religion or gender'
,
]
],
3
=>
[
'label'
=>
'Encourages or incites violence'
],
4
=>
[
'label'
=>
'Harassment'
],
5
=>
[
'label'
=>
'Contains personal and confidential info'
],
6
=>
[
'label'
=>
'Maliciously targets users (@name, links, images or videos)'
],
7
=>
[
'label'
=>
'Impersonates someone in a misleading or deceptive manner'
],
8
=>
[
'label'
=>
'Is spam'
],
9
=>
[
'label'
=>
''
],
10
=>
[
'label'
=>
'Copyright infringement'
],
11
=>
[
'label'
=>
'Another reason'
],
12
=>
[
'label'
=>
'Incorrect use of hashtags'
],
13
=>
[
'label'
=>
'Malware'
],
14
=>
[
'label'
=>
''
],
15
=>
[
'label'
=>
'Trademark infringement'
],
16
=>
[
'label'
=>
'Token manipulation'
],
]);
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment