Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
226
Issues
226
List
Boards
Labels
Service Desk
Milestones
Merge Requests
35
Merge Requests
35
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
List
Container Registry
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
Commits
a1379dea
Commit
a1379dea
authored
1 hour ago
by
Brian Hatchet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor and fixing up unit tests
parent
f310dde2
1 merge request
!335
Feat/permissions on entities 737
Pipeline
#85817722
failed with stages
in 4 minutes and 40 seconds
Changes
15
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
1478 additions
and
223 deletions
+1478
-223
Exportable.php
Api/Exportable.php
+0
-1
Factory.php
Api/Factory.php
+0
-2
Test.php.orig
Controllers/Cli/Test.php.orig
+0
-137
channel.php
Controllers/api/v1/channel.php
+0
-8
groups.php
Controllers/api/v1/groups.php
+0
-7
media.php
Controllers/api/v1/media.php
+1
-10
newsfeed.php
Controllers/api/v1/newsfeed.php
+0
-8
single.php
Controllers/api/v1/newsfeed/single.php
+1
-9
feed.php
Controllers/api/v2/boost/feed.php
+0
-9
entities.php
Controllers/api/v2/entities.php
+0
-8
feeds.php
Controllers/api/v2/feeds.php
+0
-8
container.php
Controllers/api/v2/feeds/container.php
+0
-8
subscribed.php
Controllers/api/v2/feeds/subscribed.php
+0
-8
cassandra-provision.cql.orig
Core/Provisioner/Provisioners/cassandra-provision.cql.orig
+1473
-0
ManagerSpec.php
Spec/Core/Permissions/ManagerSpec.php
+3
-0
No files found.
Api/Exportable.php
View file @
a1379dea
...
...
@@ -104,7 +104,6 @@ class Exportable implements \JsonSerializable
$exported
=
$item
->
export
(
...
$this
->
exportArgs
);
if
(
$item
&&
Di
::
_
()
->
get
(
'Features\Manager'
)
->
has
(
'permissions'
))
{
$userGuid
=
$user
?
$user
->
getGuid
()
:
null
;
$permissionsManager
=
Di
::
_
()
->
get
(
'Permissions\Manager'
);
$permissions
=
$permissionsManager
->
getList
([
'user_guid'
=>
Session
::
getLoggedinUser
(),
'entities'
=>
[
$item
]]);
...
...
This diff is collapsed.
Click to expand it.
Api/Factory.php
View file @
a1379dea
...
...
@@ -224,8 +224,6 @@ class Factory
$entities
[
$k
]
=
$entity
->
export
();
//Calculate new permissions object with the entities
if
(
$entity
&&
Di
::
_
()
->
get
(
'Features\Manager'
)
->
has
(
'permissions'
))
{
$userGuid
=
$user
?
$user
->
getGuid
()
:
null
;
$permissions
=
$permissionsManager
->
getList
([
'user_guid'
=>
Session
::
getLoggedinUser
(),
'entities'
=>
[
$entity
]]);
$entities
[
$k
][
'permissions'
]
=
$permissions
->
export
();
...
...
This diff is collapsed.
Click to expand it.
Controllers/Cli/Test.php.orig
deleted
100644 → 0
View file @
f310dde2
<?php
namespace
Minds\Controllers\Cli
;
use
Minds\Cli
;
use
Minds\Core
;
use
Minds\Core\Data\ElasticSearch
;
use
Minds\Core\Di\Di
;
use
Minds\Interfaces
;
class
Test
extends
Cli\Controller
implements
Interfaces\CliControllerInterface
{
public
function
__construct
()
{
define
(
'__MINDS_INSTALLING__'
,
true
);
}
public
function
help
(
$command
=
null
)
{
$this
->
out
(
'TBD'
);
}
public
function
exec
()
{
$client
=
Di
::
_
()
->
get
(
'Database\ElasticSearch'
);
$query
=
[
'index'
=>
'minds-boost-campaigns'
,
//'type' => 'activity',
'_source'
=>
true
,
'size'
=>
100
,
'body'
=>
[
'query'
=>
[
'bool'
=>
[
'must_not'
=>
[
[
'exists'
=>
[
'field'
=>
'@completed'
,
],
],
[
'exists'
=>
[
'field'
=>
'@rejected'
,
],
],
[
'exists'
=>
[
'field'
=>
'@revoked'
,
],
],
],
'filter'
=>
[
'script'
=>
[
'script'
=>
[
"inline"
=>
"
if(doc._index.value == 'minds-boost')
return true;
ZonedDateTime start = ZonedDateTime.ofInstant(doc.start.value.toInstant(), ZoneId.systemDefault());
ZonedDateTime end = ZonedDateTime.ofInstant(doc.end.value.toInstant(), ZoneId.systemDefault());
def totalAmountOfDays = ChronoUnit.DAYS.between(start, end);
def impressionsPerDay = doc.impressions.value / totalAmountOfDays;
ZonedDateTime now = ZonedDateTime.ofInstant(Instant.ofEpochMilli(params.nowMillis), ZoneId.systemDefault());
def passedDays = ChronoUnit.DAYS.between(now, end);
def impressionsMetPerDay = (doc.impressions_met.value ?: doc.impressions.value) / passedDays;
Debug.explain(impressionsPerDay);
return impressionsMetPerDay <= impressionsPerDay;
"
,
'lang'
=>
'painless'
,
'params'
=>
[
'nowMillis'
=>
time
()
*
1000
,
],
],
],
],
],
],
],
];
$prepared
=
new
ElasticSearch\Prepared\Search
();
$prepared
->
query
(
$query
);
try
{
$result
=
$client
->
request
(
$prepared
);
var_dump
(
$result
);
}
catch
(
\Exception
$e
)
{
var_dump
(
str_replace
(
"
\\
n"
,
"
\r\n
"
,
$e
->
getMessage
()));
}
<<<<<<<
Updated
upstream
$this
->
out
(
$namespace
);
=======
// var_dump($result);
// die();
>>>>>>>
Stashed
changes
}
private
function
getTrendingActivities
()
{
$result
=
Core\Di\Di
::
_
()
->
get
(
'Trending\Repository'
)
->
getList
([
'type'
=>
'newsfeed'
,
'limit'
=>
12
,
]);
ksort
(
$result
[
'guids'
]);
$options
[
'guids'
]
=
$result
[
'guids'
];
$activities
=
Core\Entities
::
get
(
array_merge
([
<<<<<<<
Updated
upstream
'type'
=>
'activity'
],
$options
));
=======
'type'
=>
'activity'
,
]
,
$options
));
>>>>>>>
Stashed
changes
$activities
=
array_filter
(
$activities
,
function
(
$activity
)
{
if
(
$activity
->
paywall
)
{
return
false
;
}
if
(
$activity
->
remind_object
&&
$activity
->
remind_object
[
'paywall'
])
{
return
false
;
}
return
true
;
});
return
$activities
;
}
}
This diff is collapsed.
Click to expand it.
Controllers/api/v1/channel.php
View file @
a1379dea
...
...
@@ -91,14 +91,6 @@ class channel implements Interfaces\Api
$block
=
Core\Security\ACL\Block
::
_
();
$response
[
'channel'
][
'blocked'
]
=
$block
->
isBlocked
(
$user
);
//Calculate new permissions object with the entities
if
(
$user
&&
Di
::
_
()
->
get
(
'Features\Manager'
)
->
has
(
'permissions'
))
{
$permissionsManager
=
Core\Di\Di
::
_
()
->
get
(
'Permissions\Manager'
);
$permissions
=
$permissionsManager
->
getList
([
'user_guid'
=>
Core\Session
::
getLoggedInUserGuid
(),
'entities'
=>
[
$user
]]);
$response
[
'permissions'
]
=
$permissions
;
}
if
(
$user
->
isPro
())
{
/** @var Core\Pro\Manager $manager */
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v1/groups.php
View file @
a1379dea
...
...
@@ -77,13 +77,6 @@ class groups implements Interfaces\Api
$response
[
'groups'
]
=
Factory
::
exportable
(
$groups
);
$response
[
'entities'
]
=
Factory
::
exportable
(
$groups
);
if
(
$groups
&&
Di
::
_
()
->
get
(
'Features\Manager'
)
->
has
(
'permissions'
))
{
$permissionsManager
=
Core\Di\Di
::
_
()
->
get
(
'Permissions\Manager'
);
$permissions
=
$permissionsManager
->
getList
([
'user_guid'
=>
Core\Session
::
getLoggedInUserGuid
(),
'entities'
=>
$groups
]);
$response
[
'permissions'
]
=
$permissions
;
}
if
(
!
isset
(
$response
[
'load-next'
])
&&
$groups
)
{
$response
[
'load-next'
]
=
(
string
)
end
(
$groups
)
->
getGuid
();
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v1/media.php
View file @
a1379dea
...
...
@@ -73,7 +73,7 @@ class media implements Interfaces\Api, Interfaces\ApiIgnorePam
Security\ACL
::
$ignore
=
$ignore
;
}
/*
N
o break */
/*
n
o break */
default
:
$entity
->
fullExport
=
true
;
$response
[
'entity'
]
=
$entity
->
export
();
...
...
@@ -97,15 +97,6 @@ class media implements Interfaces\Api, Interfaces\ApiIgnorePam
}
}
$currentUser
=
Core\Session
::
getLoggedinUser
();
//Calculate new permissions object with the entities
if
(
Di
::
_
()
->
get
(
'Features\Manager'
)
->
has
(
'permissions'
))
{
$permissionsManager
=
Core\Di\Di
::
_
()
->
get
(
'Permissions\Manager'
);
$permissions
=
$permissionsManager
->
getList
([
'user_guid'
=>
$currentUser
,
'entities'
=>
[
$entity
]]);
$response
[
'permissions'
]
=
$permissions
->
export
();
}
return
Factory
::
response
(
$response
);
}
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v1/newsfeed.php
View file @
a1379dea
...
...
@@ -215,14 +215,6 @@ class newsfeed implements Interfaces\Api
}
}
}
//Calculate new permissions object with the entities
if
(
$activity
&&
Di
::
_
()
->
get
(
'Features\Manager'
)
->
has
(
'permissions'
))
{
$permissionsManager
=
Core\Di\Di
::
_
()
->
get
(
'Permissions\Manager'
);
$permissions
=
$permissionsManager
->
getList
([
'user_guid'
=>
Core\Session
::
getLoggedInUserGuid
(),
'entities'
=>
$activity
]);
$response
[
'permissions'
]
=
$permissions
;
}
if
(
$activity
)
{
if
(
!
$loadNext
)
{
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v1/newsfeed/single.php
View file @
a1379dea
...
...
@@ -45,17 +45,9 @@ class newsfeed implements Interfaces\Api
}
$response
=
[
'activ
ti
y'
=>
$activity
->
export
()
'activ
it
y'
=>
$activity
->
export
()
];
//Calculate new permissions object with the entities
if
(
$activity
&&
Di
::
_
()
->
get
(
'Features\Manager'
)
->
has
(
'permissions'
))
{
$permissionsManager
=
Core\Di\Di
::
_
()
->
get
(
'Permissions\Manager'
);
$permissions
=
$permissionsManager
->
getList
([
'user_guid'
=>
Core\Session
::
getLoggedInUserGuid
(),
'entities'
=>
[
$activity
]]);
$response
[
'permissions'
]
=
$permissions
;
}
return
Factory
::
response
(
$response
);
}
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/boost/feed.php
View file @
a1379dea
...
...
@@ -151,15 +151,6 @@ class feed implements Interfaces\Api
]);
}
$permissions
=
null
;
//Calculate new permissions object with the entities
if
(
$boosts
&&
Di
::
_
()
->
get
(
'Features\Manager'
)
->
has
(
'permissions'
))
{
$permissionsManager
=
Core\Di\Di
::
_
()
->
get
(
'Permissions\Manager'
);
$permissions
=
$permissionsManager
->
getList
([
'user_guid'
=>
Core\Session
::
getLoggedInUserGuid
(),
'entities'
=>
$boosts
]);
}
return
Factory
::
response
([
'entities'
=>
Exportable
::
_
(
$boosts
),
'permissions'
=>
$permissions
,
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/entities.php
View file @
a1379dea
...
...
@@ -39,14 +39,6 @@ class entities implements Interfaces\Api
$entities
=
$resolver
->
fetch
();
$permissions
=
null
;
//Calculate new permissions object with the entities
if
(
Di
::
_
()
->
get
(
'Features\Manager'
)
->
has
(
'permissions'
))
{
$permissionsManager
=
Di
::
_
()
->
get
(
'Permissions\Manager'
);
$permissions
=
$permissionsManager
->
getList
([
'user_guid'
=>
Session
::
getLoggedInUserGuid
(),
'entities'
=>
$entities
]);
}
// Return
return
Factory
::
response
([
'entities'
=>
Exportable
::
_
(
array_values
(
$entities
)),
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/feeds.php
View file @
a1379dea
...
...
@@ -196,14 +196,6 @@ class feeds implements Interfaces\Api
}
}
$permissions
=
null
;
//Calculate new permissions object with the entities
if
(
Di
::
_
()
->
get
(
'Features\Manager'
)
->
has
(
'permissions'
))
{
$permissionsManager
=
Core\Di\Di
::
_
()
->
get
(
'Permissions\Manager'
);
$permissions
=
$permissionsManager
->
getList
([
'user_guid'
=>
$currentUser
,
'entities'
=>
$result
->
toArray
(),
]);
}
return
Factory
::
response
([
'status'
=>
'success'
,
'entities'
=>
Exportable
::
_
(
$result
),
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/feeds/container.php
View file @
a1379dea
...
...
@@ -154,14 +154,6 @@ class container implements Interfaces\Api
}
}
$permissions
=
null
;
//Calculate new permissions object with the entities
if
(
Di
::
_
()
->
get
(
'Features\Manager'
)
->
has
(
'permissions'
))
{
$permissionsManager
=
Core\Di\Di
::
_
()
->
get
(
'Permissions\Manager'
);
$permissions
=
$permissionsManager
->
getList
([
'user_guid'
=>
Core\Session
::
getLoggedInUserGuid
(),
'entities'
=>
$result
->
toArray
(),
]);
}
return
Factory
::
response
([
'status'
=>
'success'
,
'entities'
=>
Exportable
::
_
(
$result
),
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/feeds/subscribed.php
View file @
a1379dea
...
...
@@ -120,14 +120,6 @@ class subscribed implements Interfaces\Api
}
}
$permissions
=
null
;
//Calculate new permissions object with the entities
if
(
Di
::
_
()
->
get
(
'Features\Manager'
)
->
has
(
'permissions'
))
{
$permissionsManager
=
Core\Di\Di
::
_
()
->
get
(
'Permissions\Manager'
);
$permissions
=
$permissionsManager
->
getList
([
'user_guid'
=>
$currentUser
,
'entities'
=>
$result
->
toArray
()]);
}
return
Factory
::
response
([
'status'
=>
'success'
,
'entities'
=>
Exportable
::
_
(
$result
),
...
...
This diff is collapsed.
Click to expand it.
Core/Provisioner/Provisioners/cassandra-provision.cql.orig
0 → 100644
View file @
a1379dea
This diff is collapsed.
Click to expand it.
Spec/Core/Permissions/ManagerSpec.php
View file @
a1379dea
...
...
@@ -68,6 +68,9 @@ class ManagerSpec extends ObjectBehavior
"guids"
=>
[
10
,
11
,
12
,
13
],
"entities"
=>
[],
])
->
willReturn
(
$this
->
mockEntities
());
$this
->
entitiesBuilder
->
get
([
"guids"
=>
[
10
,
11
,
12
,
13
]
])
->
willReturn
(
$this
->
mockEntities
());
$this
->
beConstructedWith
(
$this
->
entitiesBuilder
);
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
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