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 (2)
(fix): don't include permissions on markers
· 09352203
Marcelo Rivera
authored
Oct 02, 2019
09352203
(fix): correctly inject permissions to exported FeedSyncEntity
· 5daa3183
Marcelo Rivera
authored
Oct 02, 2019
5daa3183
Hide whitespace changes
Inline
Side-by-side
Api/Exportable.php
View file @
5daa3183
...
...
@@ -9,6 +9,8 @@
namespace
Minds\Api
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Feeds\FeedSyncEntity
;
use
Minds\Core\Permissions\Manager
;
use
Minds\Core\Session
;
class
Exportable
implements
\JsonSerializable
...
...
@@ -104,10 +106,24 @@ class Exportable implements \JsonSerializable
$exported
=
$item
->
export
(
...
$this
->
exportArgs
);
if
(
$item
&&
Di
::
_
()
->
get
(
'Features\Manager'
)
->
has
(
'permissions'
))
{
if
(
$item
instanceof
FeedSyncEntity
&&
$item
->
getEntity
())
{
$entity
=
$item
->
getEntity
();
}
else
{
$entity
=
$item
;
}
/** @var Manager $permissionsManager */
$permissionsManager
=
Di
::
_
()
->
get
(
'Permissions\Manager'
);
$permissions
=
$permissionsManager
->
getList
([
'user_guid'
=>
Session
::
getLoggedinUser
(),
'entities'
=>
[
$item
]]);
$exported
[
'permissions'
]
=
$permissions
->
export
();
$permissions
=
$permissionsManager
->
getList
([
'user_guid'
=>
Session
::
getLoggedinUser
(),
'entities'
=>
[
$entity
],
]);
if
(
$item
instanceof
FeedSyncEntity
)
{
$exported
[
'entity'
][
'permissions'
]
=
$permissions
->
export
();
}
else
{
$exported
[
'permissions'
]
=
$permissions
->
export
();
}
}
// Shims
...
...
Api/Factory.php
View file @
5daa3183
...
...
@@ -209,13 +209,13 @@ class Factory
* @return array - an array of the entities
* @deprecated
*/
public
static
function
exportable
(
$entities
,
$exceptions
=
[],
$exportContext
=
false
)
public
static
function
exportable
(
$entities
,
$exceptions
=
[],
$exportContext
=
false
,
$includePermissions
=
true
)
{
$permissionsManager
=
Di
::
_
()
->
get
(
'Permissions\Manager'
);
if
(
!
$entities
)
{
return
[];
}
foreach
(
$entities
as
$k
=>
$entity
)
{
if
(
$exportContext
&&
method_exists
(
$entity
,
'setExportContext'
))
{
$entity
->
setExportContext
(
$exportContext
);
...
...
@@ -223,9 +223,11 @@ class Factory
$entities
[
$k
]
=
$entity
->
export
();
//Calculate new permissions object with the entities
if
(
$entity
&&
Di
::
_
()
->
get
(
'Features\Manager'
)
->
has
(
'permissions'
))
{
$permissions
=
$permissionsManager
->
getList
([
'user_guid'
=>
Session
::
getLoggedinUser
(),
'entities'
=>
[
$entity
]]);
if
(
$includePermissions
&&
$entity
&&
Di
::
_
()
->
get
(
'Features\Manager'
)
->
has
(
'permissions'
))
{
$permissions
=
$permissionsManager
->
getList
([
'user_guid'
=>
Session
::
getLoggedinUser
(),
'entities'
=>
[
$entity
],
]);
$entities
[
$k
][
'permissions'
]
=
$permissions
->
export
();
}
$entities
[
$k
][
'guid'
]
=
(
string
)
$entities
[
$k
][
'guid'
];
//javascript doesn't like long numbers..
...
...
Controllers/api/v2/notifications/markers.php
View file @
5daa3183
...
...
@@ -41,7 +41,7 @@ class markers implements Interfaces\Api
return
Factory
::
response
([
'markers'
=>
Factory
::
exportable
(
$list
),
'markers'
=>
Factory
::
exportable
(
$list
,
[],
false
,
true
),
]);
}
...
...
Core/Feeds/FeedSyncEntity.php
View file @
5daa3183
...
...
@@ -8,7 +8,7 @@
namespace
Minds\Core\Feeds
;
use
JsonSerializable
;
use
Minds\
Traits\Exportable
;
use
Minds\
Entities\Entity
;
use
Minds\Traits\MagicAttributes
;
/**
...
...
@@ -26,6 +26,7 @@ use Minds\Traits\MagicAttributes;
* @method FeedSyncEntity setAccessId(int $accessId)
* @method string getType()
* @method FeedSyncEntity setType(string $type)
* @method Entity getEntity()
*/
class
FeedSyncEntity
implements
JsonSerializable
{
...
...
@@ -68,7 +69,7 @@ class FeedSyncEntity implements JsonSerializable
{
return
[
'guid'
=>
(
string
)
$this
->
guid
,
'owner_guid'
=>
(
string
)
$this
->
ownerGuid
,
'owner_guid'
=>
(
string
)
$this
->
ownerGuid
,
'access_id'
=>
$this
->
accessId
,
'timestamp'
=>
$this
->
timestamp
,
'urn'
=>
$this
->
urn
,
...
...
Core/Permissions/Manager.php
View file @
5daa3183
...
...
@@ -45,7 +45,7 @@ class Manager
}
$guids
=
$opts
[
'guids'
]
?:
array_map
(
function
(
$item
)
{
return
$item
[
'g
uid
'
]
;
return
$item
->
getG
uid
()
;
},
$opts
[
'entities'
]);
$user
=
$this
->
entitiesBuilder
->
single
(
$opts
[
'user_guid'
]);
...
...