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
27
Merge Requests
27
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
Compare Revisions
e1f76dbc174f4a5f615d803f55b7cd32348fb2b9...2c6cbbccad72e01d1964cf45f66f3ec440d26e20
Source
2c6cbbccad72e01d1964cf45f66f3ec440d26e20
Select Git revision
...
Target
e1f76dbc174f4a5f615d803f55b7cd32348fb2b9
Select Git revision
Compare
Commits (5)
(chore): restore notifs
· 7da893d6
Mark Harding
authored
4 hours ago
7da893d6
(chore): if user then do not apply deleted flag
· 7afd2b27
Mark Harding
authored
3 hours ago
7afd2b27
(feat): remove strike on reverse
· 443429f6
Mark Harding
authored
3 hours ago
443429f6
(fix): use seconds vs microseconds
· 987cf638
Mark Harding
authored
3 hours ago
987cf638
(fix): do not save deleted flag on users
· 2c6cbbcc
Mark Harding
authored
3 hours ago
2c6cbbcc
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
92 additions
and
45 deletions
+92
-45
notifications.php
Controllers/api/v1/notifications.php
+0
-1
appeals.php
Controllers/api/v2/moderation/appeals.php
+1
-1
jury.php
Controllers/api/v2/moderation/jury.php
+1
-1
report.php
Controllers/api/v2/moderation/report.php
+1
-1
Repository.php
Core/Reports/Appeals/Repository.php
+2
-2
Manager.php
Core/Reports/Manager.php
+1
-1
Repository.php
Core/Reports/Repository.php
+1
-1
Repository.php
Core/Reports/Strikes/Repository.php
+15
-0
Manager.php
Core/Reports/UserReports/Manager.php
+3
-3
ActionDelegate.php
Core/Reports/Verdict/Delegates/ActionDelegate.php
+26
-15
ReverseActionDelegate.php
Core/Reports/Verdict/Delegates/ReverseActionDelegate.php
+40
-18
Manager.php
Core/Reports/Verdict/Manager.php
+1
-1
No files found.
Controllers/api/v1/notifications.php
View file @
2c6cbbcc
...
...
@@ -43,7 +43,6 @@ class notifications implements Interfaces\Api
{
Factory
::
isLoggedIn
();
$response
=
[];
return
;
if
(
!
isset
(
$pages
[
0
]))
{
$pages
=
[
'list'
];
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/moderation/appeals.php
View file @
2c6cbbcc
...
...
@@ -58,7 +58,7 @@ class appeals implements Interfaces\Api
$appeal
=
new
Appeal
();
$appeal
->
setNote
(
$_POST
[
'note'
])
->
setReport
(
$report
)
->
setTimestamp
(
round
(
microtime
(
true
)
*
1000
));
->
setTimestamp
(
time
(
));
$success
=
$appealManager
->
appeal
(
$appeal
);
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/moderation/jury.php
View file @
2c6cbbcc
...
...
@@ -79,7 +79,7 @@ class jury implements Interfaces\Api
->
setAppeal
(
$juryType
===
'appeal'
)
->
setUphold
(
$uphold
)
->
setReport
(
$report
)
->
setTimestamp
(
round
(
microtime
(
true
)
*
1000
))
->
setTimestamp
(
time
(
))
->
setJurorGuid
(
Core\Session
::
getLoggedInUser
()
->
getGuid
())
->
setJurorHash
(
Core\Session
::
getLoggedInUser
()
->
getPhoneNumberHash
());
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/moderation/report.php
View file @
2c6cbbcc
...
...
@@ -67,7 +67,7 @@ class report implements Interfaces\Api
$userReport
->
setReport
(
$report
)
->
setReporterGuid
(
$user
->
getGuid
())
->
setTimestamp
(
round
(
microtime
(
true
)
*
1000
));
->
setTimestamp
(
time
(
));
if
(
$user
->
getPhoneNumberHash
())
{
$userReport
->
setReporterHash
(
$user
->
getPhoneNumberHash
());
...
...
This diff is collapsed.
Click to expand it.
Core/Reports/Appeals/Repository.php
View file @
2c6cbbcc
...
...
@@ -79,12 +79,12 @@ class Repository
}
break
;
case
'approved'
:
if
(
$report
->
getState
()
!==
'appeal_jury_decided'
||
$report
->
isUpheld
()
===
fals
e
)
{
if
(
$report
->
getState
()
!==
'appeal_jury_decided'
||
$report
->
isUpheld
()
===
tru
e
)
{
$skip
=
true
;
}
break
;
case
'rejected'
:
if
(
$report
->
getState
()
!==
'appeal_jury_decided'
||
$report
->
isUpheld
()
===
tru
e
)
{
if
(
$report
->
getState
()
!==
'appeal_jury_decided'
||
$report
->
isUpheld
()
===
fals
e
)
{
$skip
=
true
;
}
break
;
...
...
This diff is collapsed.
Click to expand it.
Core/Reports/Manager.php
View file @
2c6cbbcc
...
...
@@ -64,7 +64,7 @@ class Manager
public
function
getLatestReport
(
$report
)
{
$report
->
setState
(
'reported'
)
->
setTimestamp
(
round
(
microtime
(
true
)
*
1000
));
->
setTimestamp
(
time
(
));
$reports
=
$this
->
getList
([
'entity_urn'
=>
$report
->
getEntityUrn
(),
...
...
This diff is collapsed.
Click to expand it.
Core/Reports/Repository.php
View file @
2c6cbbcc
...
...
@@ -234,7 +234,7 @@ class Repository
->
setUphold
(
isset
(
$row
[
'uphold'
])
?
(
bool
)
$row
[
'uphold'
]
:
null
)
->
setStateChanges
(
isset
(
$row
[
'state_changes'
])
?
array_map
(
function
(
$timestamp
)
{
return
$timestamp
->
microtime
(
true
);
return
$timestamp
->
time
(
);
},
$this
->
mapToAssoc
(
$row
[
'state_changes'
]))
:
null
)
...
...
This diff is collapsed.
Click to expand it.
Core/Reports/Strikes/Repository.php
View file @
2c6cbbcc
...
...
@@ -157,7 +157,22 @@ class Repository
public
function
delete
(
Strike
$strike
)
{
$statement
=
"DELETE FROM moderation_strikes
WHERE user_guid = ?
AND reason_code = ?
AND sub_reason_code = ?
AND timestamp = ?"
;
$values
=
[
new
Bigint
(
$strike
->
getUserGuid
()),
new
Tinyint
(
$strike
->
getReasonCode
()),
new
Decimal
(
$strike
->
getSubReasonCode
()),
new
Timestamp
(
$strike
->
getTimestamp
()),
];
$prepared
=
new
Prepared
();
$prepared
->
query
(
$statement
,
$values
);
return
(
bool
)
$this
->
cql
->
request
(
$prepared
);
}
}
This diff is collapsed.
Click to expand it.
Core/Reports/UserReports/Manager.php
View file @
2c6cbbcc
...
...
@@ -66,9 +66,9 @@ class Manager
if
(
$report
->
getState
()
!==
'reported'
&&
!
in_array
(
$report
->
getEntity
()
->
type
,
[
'user'
,
'group'
])
)
{
return
;
// Already past report threshold
}
elseif
(
$report
->
getState
()
===
'
clos
ed'
)
{
$report
->
setTimestamp
(
round
(
microtime
(
true
)
*
1000
));
return
true
;
// Already past report threshold
}
elseif
(
$report
->
getState
()
===
'
initial_jury_decid
ed'
)
{
$report
->
setTimestamp
(
time
(
));
}
$userReport
->
setReport
(
$report
);
...
...
This diff is collapsed.
Click to expand it.
Core/Reports/Verdict/Delegates/ActionDelegate.php
View file @
2c6cbbcc
...
...
@@ -61,9 +61,11 @@ class ActionDelegate
$entity
=
$this
->
entitiesBuilder
->
single
(
$entityGuid
);
switch
(
$report
->
getReasonCode
())
{
case
1
:
// Illegal (not appealable)
$this
->
actions
->
setDeletedFlag
(
$entity
,
true
);
$this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
case
1
:
// Illegal (not appealable)
if
(
$entity
->
type
!==
'user'
)
{
$this
->
actions
->
setDeletedFlag
(
$entity
,
true
);
$this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
}
// Ban the owner of the post too
$this
->
applyBan
(
$report
);
break
;
...
...
@@ -76,20 +78,26 @@ class ActionDelegate
$this
->
applyStrike
(
$report
);
break
;
case
3
:
// Incites violence
$this
->
actions
->
setDeletedFlag
(
$entity
,
true
);
$this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
if
(
$entity
->
type
!==
'user'
)
{
$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
();
if
(
$entity
->
type
!==
'user'
)
{
$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
();
if
(
$entity
->
type
!==
'user'
)
{
$this
->
actions
->
setDeletedFlag
(
$entity
,
true
);
$this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
}
// Ban the owner of the post too
$this
->
applyBan
(
$report
);
break
;
...
...
@@ -98,9 +106,10 @@ class ActionDelegate
$this
->
applyBan
(
$report
);
break
;
case
8
:
// Spam
$this
->
actions
->
setDeletedFlag
(
$entity
,
true
);
$this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
error_log
(
'marked as spam'
);
if
(
$entity
->
type
!==
'user'
)
{
$this
->
actions
->
setDeletedFlag
(
$entity
,
true
);
$this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
}
// Apply a strike to the owner
$this
->
applyStrike
(
$report
);
break
;
...
...
@@ -109,8 +118,10 @@ class ActionDelegate
// Apply a strike to the owner
// break;
case
13
:
// Malware
$this
->
actions
->
setDeletedFlag
(
$entity
,
true
);
$this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
if
(
$entity
->
type
!==
'user'
)
{
$this
->
actions
->
setDeletedFlag
(
$entity
,
true
);
$this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
}
// Ban the owner
$this
->
applyBan
(
$report
);
break
;
...
...
@@ -157,7 +168,7 @@ class ActionDelegate
->
setUserGuid
(
$report
->
getEntityOwnerGuid
())
->
setReasonCode
(
$report
->
getReasonCode
())
->
setSubReasonCode
(
$report
->
getSubReasonCode
())
->
setTimestamp
(
round
(
microtime
(
true
)
*
1000
));
->
setTimestamp
(
$report
->
getTimestamp
());
// Strike is recored for date of first report
$count
=
$this
->
strikesManager
->
countStrikesInTimeWindow
(
$strike
,
$this
->
strikesManager
::
STRIKE_TIME_WINDOW
);
...
...
This diff is collapsed.
Click to expand it.
Core/Reports/Verdict/Delegates/ReverseActionDelegate.php
View file @
2c6cbbcc
...
...
@@ -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
ReverseActionDelegate
{
...
...
@@ -19,6 +20,9 @@ class ReverseActionDelegate
/** @var Actions $actions */
private
$actions
;
/** @var SaveAction $saveAction */
private
$saveAction
;
/** @var Urn $urn */
private
$urn
;
...
...
@@ -29,18 +33,20 @@ class ReverseActionDelegate
$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
onReverse
(
Verdict
$verdict
)
{
if
(
!
$verdict
->
isAppeal
()
&&
$verdict
->
isUpheld
())
{
if
(
!
$verdict
->
isAppeal
()
||
$verdict
->
isUpheld
())
{
return
;
// Can not be reversed
}
...
...
@@ -55,7 +61,10 @@ class ReverseActionDelegate
switch
(
$report
->
getReasonCode
())
{
case
1
:
// Illegal (not appealable)
$this
->
actions
->
setDeletedFlag
(
$entity
,
false
);
if
(
$entity
->
type
!==
'user'
)
{
$this
->
actions
->
setDeletedFlag
(
$entity
,
false
);
$this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
}
// Ban the owner of the post too
$this
->
unBan
(
$report
);
break
;
...
...
@@ -63,22 +72,31 @@ class ReverseActionDelegate
$nsfw
=
$report
->
getSubReasonCode
();
$entity
->
setNsfw
(
array_diff
([
$nsfw
],
$entity
->
getNsfw
()));
$entity
->
setNsfwLock
(
array_diff
([
$nsfw
],
$entity
->
getNsfwLock
()));
$
entity
->
save
();
$
this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
// Apply a strike to the owner
$this
->
removeStrike
(
$report
);
break
;
case
3
:
// Incites violence
$this
->
actions
->
setDeletedFlag
(
$entity
,
false
);
if
(
$entity
->
type
!==
'user'
)
{
$this
->
actions
->
setDeletedFlag
(
$entity
,
false
);
$this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
}
// Ban the owner of the post
$this
->
unBan
(
$report
);
break
;
case
4
:
// Harrasment
$this
->
actions
->
setDeletedFlag
(
$entity
,
false
);
if
(
$entity
->
type
!==
'user'
)
{
$this
->
actions
->
setDeletedFlag
(
$entity
,
false
);
$this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
}
// Apply a strike to the owner
$this
->
removeStrike
(
$report
);
break
;
case
5
:
// Personal and confidential information (not appelable)
$this
->
actions
->
setDeletedFlag
(
$entity
,
false
);
if
(
$entity
->
type
!==
'user'
)
{
$this
->
actions
->
setDeletedFlag
(
$entity
,
false
);
$this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
}
// Ban the owner of the post too
$this
->
unBan
(
$report
);
break
;
...
...
@@ -87,7 +105,10 @@ class ReverseActionDelegate
$this
->
unBan
(
$report
);
break
;
case
8
:
// Spam
$this
->
actions
->
setDeletedFlag
(
$entity
,
false
);
if
(
$entity
->
type
!==
'user'
)
{
$this
->
actions
->
setDeletedFlag
(
$entity
,
false
);
$this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
}
// Apply a strike to the owner
$this
->
removeStrike
(
$report
);
break
;
...
...
@@ -96,7 +117,10 @@ class ReverseActionDelegate
// Apply a strike to the owner
// break;
case
13
:
// Malware
$this
->
actions
->
setDeletedFlag
(
$entity
,
false
);
if
(
$entity
->
type
!==
'user'
)
{
$this
->
actions
->
setDeletedFlag
(
$entity
,
false
);
$this
->
saveAction
->
setEntity
(
$entity
)
->
save
();
}
// Ban the owner
$this
->
unBan
(
$report
);
break
;
...
...
@@ -125,17 +149,15 @@ class ReverseActionDelegate
->
setUserGuid
(
$report
->
getEntityOwnerGuid
())
->
setReasonCode
(
$report
->
getReasonCode
())
->
setSubReasonCode
(
$report
->
getSubReasonCode
())
->
setTimestamp
(
round
(
microtime
(
true
)
*
1000
));
->
setTimestamp
(
$report
->
getTimestamp
());
// Strike is recored for date of first report
$this
->
strikesManager
->
delete
(
$strike
);
// If 3 or more strikes, ban or apply NSFW lock
if
(
$this
->
strikesManager
->
countStrikesInTimeWindow
(
$strike
,
$this
->
strikesManager
::
STRIKE_RETENTION_WINDOW
)
>=
3
)
{
if
(
$report
->
getReasonCode
()
===
2
)
{
$this
->
removeNsfwLock
(
$report
);
}
else
{
$this
->
unBan
(
$report
);
}
// Remove any bans or nsfw locks
if
(
$report
->
getReasonCode
()
===
2
)
{
$this
->
removeNsfwLock
(
$report
);
}
else
{
$this
->
unBan
(
$report
);
}
}
...
...
@@ -168,4 +190,4 @@ class ReverseActionDelegate
$user
->
save
();
}
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
Core/Reports/Verdict/Manager.php
View file @
2c6cbbcc
...
...
@@ -104,7 +104,7 @@ class Manager
{
$uphold
=
$this
->
isUpheld
(
$verdict
);
$verdict
->
setUphold
(
$uphold
);
$verdict
->
setTimestamp
(
round
(
microtime
(
true
)
*
1000
));
$verdict
->
setTimestamp
(
time
(
));
if
(
$verdict
->
isUpheld
()
===
null
)
{
error_log
(
"
{
$verdict
->
getReport
()
->
getEntityGuid
()
}
not actionable"
);
...
...
This diff is collapsed.
Click to expand it.