Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Commits on Source (5)
(chore): restore notifs
· 7da893d6
Mark Harding
authored
May 16, 2019
7da893d6
(chore): if user then do not apply deleted flag
· 7afd2b27
Mark Harding
authored
May 16, 2019
7afd2b27
(feat): remove strike on reverse
· 443429f6
Mark Harding
authored
May 16, 2019
443429f6
(fix): use seconds vs microseconds
· 987cf638
Mark Harding
authored
May 16, 2019
987cf638
(fix): do not save deleted flag on users
· 2c6cbbcc
Mark Harding
authored
May 16, 2019
2c6cbbcc
Hide whitespace changes
Inline
Side-by-side
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'
];
...
...
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
);
...
...
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
());
...
...
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
());
...
...
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
;
...
...
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
(),
...
...
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
->
micro
time
(
true
);
return
$timestamp
->
time
();
},
$this
->
mapToAssoc
(
$row
[
'state_changes'
]))
:
null
)
...
...
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
);
}
}
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
);
...
...
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
);
...
...
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
}
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"
);
...
...