Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Menu
Open sidebar
Minds
Minds Backend - Engine
Commits
aa36b0eb
Commit
aa36b0eb
authored
May 17, 2019
by
Mark Harding
Browse files
(feat): do not allow to participate in jury unless summoned
parent
22b46d5f
Pipeline
#61813319
canceled with stages
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Controllers/api/v2/moderation/jury.php
View file @
aa36b0eb
...
...
@@ -12,6 +12,7 @@ use Minds\Interfaces;
use
Minds\Core\Di\Di
;
use
Minds\Core\Reports\Jury\Decision
;
use
Minds\Core\Reports\Jury\JuryClosedException
;
use
Minds\Core\Reports\Summons\SummonsNotFoundException
;
class
jury
implements
Interfaces\Api
{
...
...
@@ -19,7 +20,7 @@ class jury implements Interfaces\Api
{
$juryType
=
$pages
[
0
]
??
'appeal'
;
if
(
$juryType
!
==
'appeal'
&&
!
Core\Session
::
isAdmin
())
{
if
(
$juryType
=
==
'appeal'
||
!
Core\Session
::
isAdmin
())
{
exit
;
}
...
...
@@ -98,6 +99,11 @@ class jury implements Interfaces\Api
'status'
=>
'error'
,
'message'
=>
'The jury has already closed'
]);
}
catch
(
SummonsNotFoundException
$e
)
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'A summons could not be found'
]);
}
return
Factory
::
response
([]);
...
...
Core/Reports/Jury/Manager.php
View file @
aa36b0eb
...
...
@@ -14,6 +14,8 @@ use Minds\Entities\NormalizedEntity;
use
Minds\Common\Repository\Response
;
use
Minds\Common\Urn
;
use
Minds\Core\Entities\Resolver
as
EntitiesResolver
;
use
Minds\Core\Reports\Summons\SummonsNotFoundException
;
use
Minds\Core\Reports\Summons\Summon
as
SummonsEntity
;
class
Manager
{
...
...
@@ -27,6 +29,9 @@ class Manager
/** @var VerdictManager $verdictManager */
private
$verdictManager
;
/** @var SummonsManager $summonsManager */
private
$summonsManager
;
/** @var string $juryType */
private
$juryType
;
...
...
@@ -36,12 +41,14 @@ class Manager
public
function
__construct
(
$repository
=
null
,
$entitiesResolver
=
null
,
$verdictManager
=
null
$verdictManager
=
null
,
$summonsManager
=
null
)
{
$this
->
repository
=
$repository
?:
new
Repository
;
$this
->
entitiesResolver
=
$entitiesResolver
?:
new
EntitiesResolver
;
$this
->
verdictManager
=
$verdictManager
?:
Di
::
_
()
->
get
(
'Moderation\Verdict\Manager'
);
$this
->
summonsManager
=
$summonsManager
?:
Di
::
_
()
->
get
(
'Moderation\Summons\Manager'
);
}
/**
...
...
@@ -135,6 +142,10 @@ class Manager
throw
new
JuryClosedException
();
}
if
(
$decision
->
isAppeal
()
&&
!
$this
->
hasSummons
(
$decision
))
{
throw
new
SummonsNotFoundException
();
}
$success
=
$this
->
repository
->
add
(
$decision
);
if
(
$decision
->
isAppeal
())
{
...
...
@@ -152,4 +163,18 @@ class Manager
return
$success
;
}
/**
* Return if a summons exists
* @param Decision $decision
* @return boolean
*/
private
function
hasSummons
(
Decision
$decision
)
{
$summons
=
new
SummonsEntity
();
$summons
->
setReportUrn
(
$decision
->
getReport
()
->
getUrn
())
->
setJurorGuid
(
$decision
->
getJurorGuid
())
->
setJuryType
(
'appeal_jury'
);
return
$this
->
summonsManager
->
isSummoned
(
$summons
);
}
}
Core/Reports/Summons/SummonsNotFoundException.php
0 → 100644
View file @
aa36b0eb
<?php
namespace
Minds\Core\Reports\Summons
;
class
SummonsNotFoundException
extends
\
Exception
{
protected
$message
=
"A summons could not be found"
;
}
Write
Preview
Supports
Markdown
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