Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
131
Issues
131
List
Boards
Labels
Service Desk
Milestones
Merge Requests
26
Merge Requests
26
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Packages
Packages
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
c0411b84
Commit
c0411b84
authored
1 hour ago
by
Mark Harding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(wip): staging work in progress changes
parent
fb2a961c
epic/ReportingAndModeration
1 merge request
!100
Epic/reporting and moderation
Pipeline
#61523350
failed with stages
in 3 minutes and 54 seconds
Changes
14
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
82 additions
and
28 deletions
+82
-28
jury.php
Controllers/api/v2/moderation/jury.php
+6
-6
report.php
Controllers/api/v2/moderation/report.php
+4
-0
EntityGuidResolverDelegate.php
Core/Entities/Delegates/EntityGuidResolverDelegate.php
+1
-1
Repository.php
Core/Reports/Appeals/Repository.php
+2
-2
Manager.php
Core/Reports/Manager.php
+2
-2
Repository.php
Core/Reports/Repository.php
+3
-3
Manager.php
Core/Reports/Strikes/Manager.php
+13
-3
Repository.php
Core/Reports/Strikes/Repository.php
+4
-4
Repository.php
Core/Reports/UserReports/Repository.php
+1
-1
ActionDelegate.php
Core/Reports/Verdict/Delegates/ActionDelegate.php
+18
-4
Repository.php
Core/Reports/Verdict/Repository.php
+3
-1
ACL.php
Core/Security/ACL.php
+14
-0
User.php
Entities/User.php
+9
-0
ElggUser.php
classes/ElggUser.php
+2
-1
No files found.
Controllers/api/v2/moderation/jury.php
View file @
c0411b84
...
...
@@ -19,7 +19,7 @@ class jury implements Interfaces\Api
$juryType
=
$pages
[
0
]
??
'appeal'
;
if
(
$juryType
!==
'appeal'
&&
!
Core\Session
::
isAdmin
())
{
//
exit;
exit
;
}
$juryManager
=
Di
::
_
()
->
get
(
'Moderation\Jury\Manager'
);
...
...
@@ -39,7 +39,7 @@ class jury implements Interfaces\Api
public
function
post
(
$pages
)
{
$juryType
=
$pages
[
0
]
??
null
;
$
entityGuid
=
$pages
[
1
]
??
null
;
$
urn
=
$pages
[
1
]
??
null
;
$uphold
=
$_POST
[
'uphold'
]
??
null
;
if
(
!
$juryType
)
{
...
...
@@ -49,10 +49,10 @@ class jury implements Interfaces\Api
]);
}
if
(
!
$
entityGuid
)
{
if
(
!
$
urn
)
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'You must supply the entity
guid in the URI like /:juryType/:entityGuid
'
,
'message'
=>
'You must supply the entity
urn in the URI like /:juryType/:urn
'
,
]);
}
...
...
@@ -63,7 +63,7 @@ class jury implements Interfaces\Api
]);
}
if
(
!
Core\Session
::
getLoggedInUser
()
->
getPhoneNumberHash
()
&&
false
)
{
if
(
!
Core\Session
::
getLoggedInUser
()
->
getPhoneNumberHash
())
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'juror must be in the rewards program'
,
...
...
@@ -72,7 +72,7 @@ class jury implements Interfaces\Api
$juryManager
=
Di
::
_
()
->
get
(
'Moderation\Jury\Manager'
);
$moderationManager
=
Di
::
_
()
->
get
(
'Moderation\Manager'
);
$report
=
$moderationManager
->
getReport
(
$
entityGuid
);
$report
=
$moderationManager
->
getReport
(
$
urn
);
$decision
=
new
Decision
();
$decision
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/moderation/report.php
View file @
c0411b84
...
...
@@ -69,6 +69,10 @@ class report implements Interfaces\Api
->
setReporterGuid
(
$user
->
getGuid
())
->
setTimestamp
(
round
(
microtime
(
true
)
*
1000
));
if
(
$user
->
getPhoneNumberHash
())
{
$userReport
->
setReporterHash
(
$user
->
getPhoneNumberHash
());
}
if
(
!
$manager
->
add
(
$userReport
))
{
return
Factory
::
response
([
'status'
=>
'error'
,
...
...
This diff is collapsed.
Click to expand it.
Core/Entities/Delegates/EntityGuidResolverDelegate.php
View file @
c0411b84
...
...
@@ -34,7 +34,7 @@ class EntityGuidResolverDelegate implements ResolverDelegate
*/
public
function
shouldResolve
(
Urn
$urn
)
{
return
$urn
->
getNid
()
===
'entity'
||
$urn
->
getNid
()
===
'activity'
;
return
$urn
->
getNid
()
===
'entity'
||
$urn
->
getNid
()
===
'activity'
||
$urn
->
getNid
()
===
'user'
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
Core/Reports/Appeals/Repository.php
View file @
c0411b84
...
...
@@ -79,12 +79,12 @@ class Repository
}
break
;
case
'approved'
:
if
(
$report
->
getState
()
!=
'appeal_jury_decided'
&&
$report
->
isUpheld
()
===
false
)
{
if
(
$report
->
getState
()
!=
=
'appeal_jury_decided'
||
$report
->
isUpheld
()
===
false
)
{
$skip
=
true
;
}
break
;
case
'rejected'
:
if
(
$report
->
getState
()
!=
'appeal_jury_decided'
&&
$report
->
isUpheld
()
===
true
)
{
if
(
$report
->
getState
()
!=
=
'appeal_jury_decided'
||
$report
->
isUpheld
()
===
true
)
{
$skip
=
true
;
}
break
;
...
...
This diff is collapsed.
Click to expand it.
Core/Reports/Manager.php
View file @
c0411b84
...
...
@@ -40,9 +40,9 @@ class Manager
return
$this
->
repository
->
getList
(
$opts
);
}
public
function
getReport
(
$
entity_guid
)
public
function
getReport
(
$
urn
)
{
return
$this
->
repository
->
get
(
$
entity_guid
);
return
$this
->
repository
->
get
(
$
urn
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Core/Reports/Repository.php
View file @
c0411b84
...
...
@@ -104,12 +104,12 @@ class Repository
$values
[]
=
$opts
[
'entity_urn'
];
}
if
(
$opts
[
'reason_code'
]
)
{
if
(
isset
(
$opts
[
'reason_code'
])
)
{
$where
[]
=
"reason_code = ?"
;
$values
[]
=
new
Tinyint
(
$opts
[
'reason_code'
]);
}
if
(
$opts
[
'sub_reason_code'
]
)
{
if
(
isset
(
$opts
[
'sub_reason_code'
])
)
{
$where
[]
=
"sub_reason_code = ?"
;
$values
[]
=
new
Decimal
(
$opts
[
'sub_reason_code'
]);
}
...
...
@@ -156,7 +156,7 @@ class Repository
'sub_reason_code'
=>
$subReasonCode
,
'timestamp'
=>
$timestamp
,
]);
if
(
!
$response
[
0
])
{
return
null
;
}
...
...
This diff is collapsed.
Click to expand it.
Core/Reports/Strikes/Manager.php
View file @
c0411b84
...
...
@@ -7,8 +7,8 @@ namespace Minds\Core\Reports\Strikes;
class
Manager
{
//
const STRIKE_TIME_WINDOW = (60 * 60) * 24; // 24 hours
const
STRIKE_TIME_WINDOW
=
60
;
const
STRIKE_TIME_WINDOW
=
(
60
*
60
)
*
24
;
// 24 hours
//
const STRIKE_TIME_WINDOW = 60;
const
STRIKE_RETENTION_WINDOW
=
(
60
*
60
)
*
24
*
90
;
// 90 days
/** @var Repository $repository */
...
...
@@ -70,4 +70,14 @@ class Manager
return
count
(
$strikes
);
}
}
\ No newline at end of file
/**
* Delete a strike
* @param Strike $strike
* @return bool
*/
public
function
delete
(
$strike
)
{
return
$this
->
repository
->
delete
(
$strike
);
}
}
This diff is collapsed.
Click to expand it.
Core/Reports/Strikes/Repository.php
View file @
c0411b84
...
...
@@ -55,12 +55,12 @@ class Repository
new
Bigint
(
$opts
[
'user_guid'
]),
];
if
(
$opts
[
'reason_code'
]
)
{
if
(
isset
(
$opts
[
'reason_code'
])
)
{
$statement
.=
" AND reason_code = ?"
;
$values
[]
=
new
Tinyint
(
$opts
[
'reason_code'
]);
}
if
(
$opts
[
'sub_reason_code'
]
)
{
if
(
isset
(
$opts
[
'sub_reason_code'
])
)
{
$statement
.=
" AND sub_reason_code = ?"
;
$values
[]
=
new
Decimal
(
$opts
[
'sub_reason_code'
]);
}
...
...
@@ -80,7 +80,7 @@ class Repository
$values
[]
=
new
Timestamp
(
$opts
[
'to'
]
*
1000
);
}
if
(
!
$opts
[
'reason_code'
]
&&
!
$opts
[
'sub_reason_code'
]
)
{
if
(
!
isset
(
$opts
[
'reason_code'
])
&&
!
isset
(
$opts
[
'sub_reason_code'
])
)
{
$statement
.=
" ALLOW FILTERING"
;
}
...
...
@@ -160,4 +160,4 @@ class Repository
}
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
Core/Reports/UserReports/Repository.php
View file @
c0411b84
...
...
@@ -75,7 +75,7 @@ class Repository
AND timestamp = ?"
;
$values
[]
=
$report
->
getReport
()
->
getEntityUrn
();
$values
[]
=
new
Tinyint
(
$report
->
getReport
()
->
getReasonCode
());
$values
[]
=
new
Decimal
(
$report
->
getReport
()
->
getSubReasonCode
());
$values
[]
=
new
Decimal
(
$report
->
getReport
()
->
getSubReasonCode
()
??
0
);
$values
[]
=
new
Timestamp
(
$report
->
getReport
()
->
getTimestamp
());
$prepared
=
new
Prepared
;
...
...
This diff is collapsed.
Click to expand it.
Core/Reports/Verdict/Delegates/ActionDelegate.php
View file @
c0411b84
...
...
@@ -10,6 +10,7 @@ use Minds\Core\Di\Di;
use
Minds\Common\Urn
;
use
Minds\Core\Reports\Report
;
use
Minds\Core\Reports\Strikes\Strike
;
use
Minds\Core\Entities\Actions\Save
as
SaveAction
;
class
ActionDelegate
{
...
...
@@ -19,6 +20,9 @@ class ActionDelegate
/** @var Actions $actions */
private
$actions
;
/** @var SaveAction $saveAction */
private
$saveAction
;
/** @var Urn $urn */
private
$urn
;
...
...
@@ -29,18 +33,21 @@ class ActionDelegate
$entitiesBuilder
=
null
,
$actions
=
null
,
$urn
=
null
,
$strikesManager
=
null
$strikesManager
=
null
,
$saveAction
=
null
)
{
$this
->
entitiesBuilder
=
$entitiesBuilder
?:
Di
::
_
()
->
get
(
'EntitiesBuilder'
);
$this
->
actions
=
$actions
?:
Di
::
_
()
->
get
(
'Reports\Actions'
);
$this
->
urn
=
$urn
?:
new
Urn
;
$this
->
strikesManager
=
$strikesManager
?:
Di
::
_
()
->
get
(
'Moderation\Strikes\Manager'
);
$this
->
saveAction
=
$saveAction
?:
new
SaveAction
;
}
public
function
onAction
(
Verdict
$verdict
)
{
if
(
$verdict
->
isAppeal
())
{
if
(
$verdict
->
isAppeal
()
||
!
$verdict
->
isUpheld
())
{
error_log
(
'Not upheld so no action'
);
return
;
// Can not
}
...
...
@@ -56,6 +63,7 @@ class ActionDelegate
switch
(
$report
->
getReasonCode
())
{
case
1
:
// Illegal (not appealable)
$this
->
actions
->
setDeletedFlag
(
$entity
,
true
);
$this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
// Ban the owner of the post too
$this
->
applyBan
(
$report
);
break
;
...
...
@@ -63,22 +71,25 @@ class ActionDelegate
$nsfw
=
$report
->
getSubReasonCode
();
$entity
->
setNsfw
(
array_merge
([
$nsfw
],
$entity
->
getNsfw
()));
$entity
->
setNsfwLock
(
array_merge
([
$nsfw
],
$entity
->
getNsfwLock
()));
$
entity
->
save
();
$
this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
// Apply a strike to the owner
$this
->
applyStrike
(
$report
);
break
;
case
3
:
// Incites violence
$this
->
actions
->
setDeletedFlag
(
$entity
,
true
);
$this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
// Ban the owner of the post
$this
->
applyBan
(
$report
);
break
;
case
4
:
// Harrasment
$this
->
actions
->
setDeletedFlag
(
$entity
,
true
);
$this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
// Apply a strike to the owner
$this
->
applyStrike
(
$report
);
break
;
case
5
:
// Personal and confidential information (not appelable)
$this
->
actions
->
setDeletedFlag
(
$entity
,
true
);
$this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
// Ban the owner of the post too
$this
->
applyBan
(
$report
);
break
;
...
...
@@ -88,6 +99,8 @@ class ActionDelegate
break
;
case
8
:
// Spam
$this
->
actions
->
setDeletedFlag
(
$entity
,
true
);
$this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
error_log
(
'marked as spam'
);
// Apply a strike to the owner
$this
->
applyStrike
(
$report
);
break
;
...
...
@@ -97,6 +110,7 @@ class ActionDelegate
// break;
case
13
:
// Malware
$this
->
actions
->
setDeletedFlag
(
$entity
,
true
);
$this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
// Ban the owner
$this
->
applyBan
(
$report
);
break
;
...
...
@@ -194,4 +208,4 @@ class ActionDelegate
$user
->
save
();
}
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
Core/Reports/Verdict/Repository.php
View file @
c0411b84
...
...
@@ -65,7 +65,8 @@ class Repository
$statement
=
"UPDATE moderation_reports
SET state = ?,
state_changes += ?
state_changes += ?,
uphold = ?
WHERE entity_urn = ?
AND reason_code = ?
AND sub_reason_code = ?
...
...
@@ -79,6 +80,7 @@ class Repository
$values
=
[
$state
,
$stateChangesMap
,
(
bool
)
$verdict
->
isUpheld
(),
$verdict
->
getReport
()
->
getEntityUrn
(),
new
Tinyint
(
$verdict
->
getReport
()
->
getReasonCode
()),
new
Decimal
(
$verdict
->
getReport
()
->
getSubReasonCode
()),
...
...
This diff is collapsed.
Click to expand it.
Core/Security/ACL.php
View file @
c0411b84
...
...
@@ -147,6 +147,13 @@ class ACL
return
false
;
}
/**
* If the user is banned or in a limited state
*/
if
(
$user
->
isBanned
()
||
!
$user
->
isEnabled
())
{
return
false
;
}
/**
* Does the user own the entity, or is it the container?
*/
...
...
@@ -227,6 +234,13 @@ class ACL
return
false
;
}
/**
* If the user is banned or in a limited state
*/
if
(
$user
->
isBanned
()
||
!
$user
->
isEnabled
())
{
return
false
;
}
/**
* Check if we are the owner
*/
...
...
This diff is collapsed.
Click to expand it.
Entities/User.php
View file @
c0411b84
...
...
@@ -1035,4 +1035,13 @@ class User extends \ElggUser
return
$this
;
}
/**
* Preferred urn
* @return string
*/
public
function
getUrn
()
{
return
"urn:user:
{
$this
->
getGuid
()
}
"
;
}
}
This diff is collapsed.
Click to expand it.
classes/ElggUser.php
View file @
c0411b84
...
...
@@ -734,7 +734,8 @@ class ElggUser extends ElggEntity
'icontime'
,
'legacy_guid'
,
'featured_id'
,
'banned'
'banned'
,
'ban_reason'
,
));
}
...
...
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