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 (3)
(fix): do not allow votes in jury if the jury is closed
· 7f97f49c
Mark Harding
authored
May 16, 2019
7f97f49c
(feat): return report by urn on repo
· 545f6462
Mark Harding
authored
May 16, 2019
545f6462
(fix): use seconds not milliseconds
· cf8726fa
Mark Harding
authored
May 16, 2019
cf8726fa
Hide whitespace changes
Inline
Side-by-side
Controllers/api/v2/moderation/jury.php
View file @
cf8726fa
...
...
@@ -11,6 +11,7 @@ use Minds\Entities\Activity;
use
Minds\Interfaces
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Reports\Jury\Decision
;
use
Minds\Core\Reports\Jury\JuryClosedException
;
class
jury
implements
Interfaces\Api
{
...
...
@@ -26,6 +27,13 @@ class jury implements Interfaces\Api
$juryManager
->
setJuryType
(
$juryType
)
->
setUser
(
Core\Session
::
getLoggedInUser
());
if
(
isset
(
$pages
[
1
]))
{
$report
=
$juryManager
->
getReport
(
$pages
[
1
]);
return
Factory
::
response
([
'report'
=>
$report
?
$report
->
export
()
:
null
,
]);
}
$reports
=
$juryManager
->
getUnmoderatedList
([
'limit'
=>
12
,
'hydrate'
=>
true
,
...
...
@@ -83,7 +91,14 @@ class jury implements Interfaces\Api
->
setJurorGuid
(
Core\Session
::
getLoggedInUser
()
->
getGuid
())
->
setJurorHash
(
Core\Session
::
getLoggedInUser
()
->
getPhoneNumberHash
());
$juryManager
->
cast
(
$decision
);
try
{
$juryManager
->
cast
(
$decision
);
}
catch
(
JuryClosedException
$e
)
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'The jury has already closed'
]);
}
return
Factory
::
response
([]);
}
...
...
Core/Reports/Jury/JuryClosedException.php
0 → 100644
View file @
cf8726fa
<?php
namespace
Minds\Core\Reports\Jury
;
class
JuryClosedException
extends
\Exception
{
protected
$message
=
"The jury has closed"
;
}
Core/Reports/Jury/Manager.php
View file @
cf8726fa
...
...
@@ -105,6 +105,23 @@ class Manager
return
$response
;
}
/**
* Return a single report
* @param string $urn
* @return Report
*/
public
function
getReport
(
$urn
)
{
$report
=
$this
->
repository
->
get
(
$urn
);
if
(
$report
)
{
$entity
=
$this
->
entitiesResolver
->
single
(
(
new
Urn
())
->
setUrn
(
$report
->
getEntityUrn
())
);
$report
->
setEntity
(
$entity
);
}
return
$report
;
}
/**
* Cast a decision
* @param Decision $decision
...
...
@@ -112,9 +129,14 @@ class Manager
*/
public
function
cast
(
Decision
$decision
)
{
$report
=
$decision
->
getReport
();
if
(
!
in_array
(
$report
->
getState
(),
[
'reported'
,
'appealed'
]))
{
throw
new
JuryClosedException
();
}
$success
=
$this
->
repository
->
add
(
$decision
);
$report
=
$decision
->
getReport
();
if
(
$decision
->
isAppeal
())
{
$decisions
=
$report
->
getAppealJuryDecisions
();
$decisions
[]
=
$decision
;
...
...
Core/Reports/Jury/Repository.php
View file @
cf8726fa
...
...
@@ -53,7 +53,7 @@ class Repository
],
$opts
);
if
(
!
$opts
[
'user'
]
->
getPhoneNumberHash
())
{
//
return null;
return
null
;
}
$statement
=
"SELECT * FROM moderation_reports_by_state
...
...
@@ -89,6 +89,18 @@ class Repository
return
$response
;
}
/**
* Return a single report
* @param string $urn
* @return Report
*/
public
function
get
(
$urn
)
{
// TODO: Do not return if we no longer meet criteria
return
$this
->
reportsRepository
->
get
(
$urn
);
}
/**
* Add a decision for a report
* @param Decision $decision
...
...
Core/Reports/Strikes/Repository.php
View file @
cf8726fa
...
...
@@ -72,12 +72,12 @@ class Repository
if
(
$opts
[
'from'
])
{
$statement
.
=
" AND timestamp > ?"
;
$values
[]
=
new
Timestamp
(
$opts
[
'from'
]
*
1000
);
$values
[]
=
new
Timestamp
(
$opts
[
'from'
]);
}
if
(
$opts
[
'to'
])
{
$statement
.
=
" AND timestamp < ?"
;
$values
[]
=
new
Timestamp
(
$opts
[
'to'
]
*
1000
);
$values
[]
=
new
Timestamp
(
$opts
[
'to'
]);
}
if
(
!
isset
(
$opts
[
'reason_code'
])
&&
!
isset
(
$opts
[
'sub_reason_code'
]))
{
...
...