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
36
Merge Requests
36
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
11046c94
Commit
11046c94
authored
17 minutes ago
by
Brian Hatchet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removing the kudzu, now we don't need to touch every entity
parent
a1379dea
feat/permissions-on-entities-737
1 merge request
!335
Feat/permissions on entities 737
Pipeline
#85821429
failed with stages
in 4 minutes and 22 seconds
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
39 additions
and
142 deletions
+39
-142
media.php
Controllers/api/v1/media.php
+1
-3
recommended.php
Controllers/api/v1/media/recommended.php
+1
-11
newsfeed.php
Controllers/api/v1/newsfeed.php
+1
-5
single.php
Controllers/api/v1/newsfeed/single.php
+0
-65
feed.php
Controllers/api/v2/boost/feed.php
+0
-1
entities.php
Controllers/api/v2/entities.php
+9
-19
feeds.php
Controllers/api/v2/feeds.php
+8
-8
container.php
Controllers/api/v2/feeds/container.php
+10
-15
subscribed.php
Controllers/api/v2/feeds/subscribed.php
+9
-15
No files found.
Controllers/api/v1/media.php
View file @
11046c94
...
...
@@ -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
();
...
...
@@ -92,8 +92,6 @@ class media implements Interfaces\Api, Interfaces\ApiIgnorePam
$response
[
'entity'
][
'canEdit'
]
=
$entity
->
canEdit
();
Security\ACL
::
$ignore
=
$ignore
;
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v1/media/recommended.php
View file @
11046c94
...
...
@@ -112,19 +112,9 @@ class recommended implements Interfaces\Api
// Trim to correct length
$entities
=
array_slice
(
$entities
,
0
,
$limit
);
$permissions
=
null
;
$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'
=>
$entities
]);
}
return
Factory
::
response
([
'entities'
=>
Factory
::
exportable
(
$entities
),
'permissions'
=>
$permissions
,
'entities'
=>
Factory
::
exportable
(
$entities
)
]);
}
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v1/newsfeed.php
View file @
11046c94
...
...
@@ -40,7 +40,6 @@ class newsfeed implements Interfaces\Api
$pinned_guids
=
null
;
switch
(
$pages
[
0
])
{
/* Refactored to it's own controller
case
'single'
:
$activity
=
new
Activity
(
$pages
[
1
]);
...
...
@@ -57,7 +56,6 @@ class newsfeed implements Interfaces\Api
return
Factory
::
response
([
'activity'
=>
$activity
->
export
()]);
break
;
*/
default
:
case
'personal'
:
$options
=
[
...
...
@@ -170,8 +168,6 @@ class newsfeed implements Interfaces\Api
array_shift
(
$activity
);
}
$loadPrevious
=
$activity
?
(
string
)
current
(
$activity
)
->
guid
:
''
;
// \Minds\Helpers\Counters::incrementBatch($activity, 'impression');
...
...
@@ -215,7 +211,7 @@ class newsfeed implements Interfaces\Api
}
}
}
if
(
$activity
)
{
if
(
!
$loadNext
)
{
$loadNext
=
(
string
)
end
(
$activity
)
->
guid
;
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v1/newsfeed/single.php
deleted
100644 → 0
View file @
a1379dea
<?php
/**
* Minds Newsfeed Single refactor API
*
* @version 1
* @author Brian Hatchet
*/
namespace
Minds\Controllers\api\v1
;
use
Minds\Api\Factory
;
use
Minds\Core
;
use
Minds\Core\Security
;
use
Minds\Entities
;
use
Minds\Entities\Activity
;
use
Minds\Helpers
;
use
Minds\Entities\Factory
as
EntitiesFactory
;
use
Minds\Helpers\Counters
;
use
Minds\Interfaces
;
use
Minds\Interfaces\Flaggable
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Entities\Actions\Save
;
class
newsfeed
implements
Interfaces\Api
{
/**
* Returns the newsfeed
* @param array $pages
*
* API:: /v1/newsfeed/single/:guid
*/
public
function
get
(
$pages
)
{
$activity
=
new
Activity
(
$pages
[
1
]);
if
(
!
Security\ACL
::
_
()
->
read
(
$activity
))
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'You do not have permission to view this post'
]);
}
if
(
!
$activity
->
guid
||
Helpers\Flags
::
shouldFail
(
$activity
))
{
return
Factory
::
response
([
'status'
=>
'error'
]);
}
$response
=
[
'activity'
=>
$activity
->
export
()
];
return
Factory
::
response
(
$response
);
}
public
function
post
(
$pages
)
{
}
public
function
put
(
$pages
)
{
}
public
function
delete
(
$pages
)
{
}
}
This diff is collapsed.
Click to expand it.
Controllers/api/v2/boost/feed.php
View file @
11046c94
...
...
@@ -153,7 +153,6 @@ class feed implements Interfaces\Api
return
Factory
::
response
([
'entities'
=>
Exportable
::
_
(
$boosts
),
'permissions'
=>
$permissions
,
'load-next'
=>
$next
?:
null
,
]);
}
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/entities.php
View file @
11046c94
...
...
@@ -13,15 +13,12 @@ use Minds\Common\Urn;
use
Minds\Core\Entities\Resolver
;
use
Minds\Core\Session
;
use
Minds\Interfaces
;
use
Minds\Core\Di\Di
;
class
entities
implements
Interfaces\Api
{
/**
* Equivalent to HTTP GET method.
*
* @param array $pages
*
* Equivalent to HTTP GET method
* @param array $pages
* @return mixed|null
*/
public
function
get
(
$pages
)
...
...
@@ -34,7 +31,7 @@ class entities implements Interfaces\Api
->
setUser
(
Session
::
getLoggedinUser
()
?:
null
)
->
setUrns
(
$urns
)
->
setOpts
([
'asActivities'
=>
$asActivities
,
'asActivities'
=>
$asActivities
]);
$entities
=
$resolver
->
fetch
();
...
...
@@ -42,15 +39,12 @@ class entities implements Interfaces\Api
// Return
return
Factory
::
response
([
'entities'
=>
Exportable
::
_
(
array_values
(
$entities
)),
'permissions'
=>
$permissions
,
]);
}
/**
* Equivalent to HTTP POST method.
*
* @param array $pages
*
* Equivalent to HTTP POST method
* @param array $pages
* @return mixed|null
*/
public
function
post
(
$pages
)
...
...
@@ -59,10 +53,8 @@ class entities implements Interfaces\Api
}
/**
* Equivalent to HTTP PUT method.
*
* @param array $pages
*
* Equivalent to HTTP PUT method
* @param array $pages
* @return mixed|null
*/
public
function
put
(
$pages
)
...
...
@@ -71,10 +63,8 @@ class entities implements Interfaces\Api
}
/**
* Equivalent to HTTP DELETE method.
*
* @param array $pages
*
* Equivalent to HTTP DELETE method
* @param array $pages
* @return mixed|null
*/
public
function
delete
(
$pages
)
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/feeds.php
View file @
11046c94
...
...
@@ -13,10 +13,8 @@ use Minds\Interfaces;
class
feeds
implements
Interfaces\Api
{
/**
* Gets a list of suggested hashtags, including the ones the user has opted in.
*
* Gets a list of suggested hashtags, including the ones the user has opted in
* @param array $pages
*
* @throws \Exception
*/
public
function
get
(
$pages
)
...
...
@@ -31,7 +29,7 @@ class feeds implements Interfaces\Api
if
(
!
$filter
)
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'Invalid filter'
,
'message'
=>
'Invalid filter'
]);
}
...
...
@@ -40,7 +38,7 @@ class feeds implements Interfaces\Api
if
(
!
$algorithm
)
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'Invalid algorithm'
,
'message'
=>
'Invalid algorithm'
]);
}
...
...
@@ -74,6 +72,8 @@ class feeds implements Interfaces\Api
$period
=
'1y'
;
}
//
$hardLimit
=
600
;
if
(
$currentUser
&&
$currentUser
->
isAdmin
())
{
...
...
@@ -105,6 +105,8 @@ class feeds implements Interfaces\Api
]);
}
//
$hashtag
=
null
;
if
(
isset
(
$_GET
[
'hashtag'
]))
{
$hashtag
=
strtolower
(
$_GET
[
'hashtag'
]);
...
...
@@ -130,7 +132,7 @@ class feeds implements Interfaces\Api
if
(
!
$container
||
!
Core\Security\ACL
::
_
()
->
read
(
$container
))
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'Forbidden'
,
'message'
=>
'Forbidden'
]);
}
}
...
...
@@ -200,11 +202,9 @@ class feeds implements Interfaces\Api
'status'
=>
'success'
,
'entities'
=>
Exportable
::
_
(
$result
),
'load-next'
=>
$limit
+
$offset
,
'permissions'
=>
$permissions
,
]);
}
catch
(
\Exception
$e
)
{
error_log
(
$e
);
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
$e
->
getMessage
()]);
}
}
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/feeds/container.php
View file @
11046c94
...
...
@@ -13,12 +13,9 @@ use Minds\Interfaces;
class
container
implements
Interfaces\Api
{
/**
* Equivalent to HTTP GET method.
*
* Equivalent to HTTP GET method
* @param array $pages
*
* @return mixed|null
*
* @throws \Exception
*/
public
function
get
(
$pages
)
...
...
@@ -26,6 +23,8 @@ class container implements Interfaces\Api
/** @var User $currentUser */
$currentUser
=
Core\Session
::
getLoggedinUser
();
//
$container_guid
=
$pages
[
0
]
??
null
;
if
(
!
$container_guid
)
{
...
...
@@ -63,6 +62,8 @@ class container implements Interfaces\Api
break
;
}
//
$hardLimit
=
5000
;
$offset
=
0
;
...
...
@@ -89,6 +90,8 @@ class container implements Interfaces\Api
]);
}
//
$sync
=
(
bool
)
(
$_GET
[
'sync'
]
??
false
);
$fromTimestamp
=
$_GET
[
'from_timestamp'
]
??
0
;
...
...
@@ -158,20 +161,16 @@ class container implements Interfaces\Api
'status'
=>
'success'
,
'entities'
=>
Exportable
::
_
(
$result
),
'load-next'
=>
$result
->
getPagingToken
(),
'permissions'
=>
$permissions
,
]);
}
catch
(
\Exception
$e
)
{
error_log
(
$e
);
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
$e
->
getMessage
()]);
}
}
/**
* Equivalent to HTTP POST method.
*
* Equivalent to HTTP POST method
* @param array $pages
*
* @return mixed|null
*/
public
function
post
(
$pages
)
...
...
@@ -180,10 +179,8 @@ class container implements Interfaces\Api
}
/**
* Equivalent to HTTP PUT method.
*
* Equivalent to HTTP PUT method
* @param array $pages
*
* @return mixed|null
*/
public
function
put
(
$pages
)
...
...
@@ -192,10 +189,8 @@ class container implements Interfaces\Api
}
/**
* Equivalent to HTTP DELETE method.
*
* Equivalent to HTTP DELETE method
* @param array $pages
*
* @return mixed|null
*/
public
function
delete
(
$pages
)
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/feeds/subscribed.php
View file @
11046c94
...
...
@@ -6,18 +6,16 @@ use Minds\Api\Exportable;
use
Minds\Api\Factory
;
use
Minds\Core
;
use
Minds\Core\Di\Di
;
use
Minds\Entities\Factory
as
EntitiesFactory
;
use
Minds\Entities\User
;
use
Minds\Interfaces
;
class
subscribed
implements
Interfaces\Api
{
/**
* Equivalent to HTTP GET method.
*
* Equivalent to HTTP GET method
* @param array $pages
*
* @return mixed|null
*
* @throws \Exception
*/
public
function
get
(
$pages
)
...
...
@@ -43,6 +41,8 @@ class subscribed implements Interfaces\Api
break
;
}
//
$hardLimit
=
5000
;
$offset
=
0
;
...
...
@@ -69,6 +69,8 @@ class subscribed implements Interfaces\Api
]);
}
//
$sync
=
(
bool
)
(
$_GET
[
'sync'
]
??
false
);
$fromTimestamp
=
$_GET
[
'from_timestamp'
]
??
0
;
...
...
@@ -124,20 +126,16 @@ class subscribed implements Interfaces\Api
'status'
=>
'success'
,
'entities'
=>
Exportable
::
_
(
$result
),
'load-next'
=>
$result
->
getPagingToken
(),
'permissions'
=>
$permissions
,
]);
}
catch
(
\Exception
$e
)
{
error_log
(
$e
);
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
$e
->
getMessage
()]);
}
}
/**
* Equivalent to HTTP POST method.
*
* Equivalent to HTTP POST method
* @param array $pages
*
* @return mixed|null
*/
public
function
post
(
$pages
)
...
...
@@ -146,10 +144,8 @@ class subscribed implements Interfaces\Api
}
/**
* Equivalent to HTTP PUT method.
*
* Equivalent to HTTP PUT method
* @param array $pages
*
* @return mixed|null
*/
public
function
put
(
$pages
)
...
...
@@ -158,10 +154,8 @@ class subscribed implements Interfaces\Api
}
/**
* Equivalent to HTTP DELETE method.
*
* Equivalent to HTTP DELETE method
* @param array $pages
*
* @return mixed|null
*/
public
function
delete
(
$pages
)
...
...
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