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
244
Issues
244
List
Boards
Labels
Service Desk
Milestones
Merge Requests
30
Merge Requests
30
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
63c28906
Commit
63c28906
authored
1 hour ago
by
Juan Manuel Solaro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(feat) add filter by scheduled for entities resolver and adapt code as per review
parent
2bda8429
epic/post-scheduler
1 merge request
!294
WIP: epic/post-scheduler
Pipeline
#79426407
failed with stages
in 4 minutes and 56 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
9 deletions
+65
-9
scheduled.php
Controllers/api/v2/feeds/scheduled.php
+6
-0
TimeCreatedDelegate.php
Core/Blogs/Delegates/TimeCreatedDelegate.php
+1
-1
FilterEntitiesDelegate.php
Core/Entities/Delegates/FilterEntitiesDelegate.php
+52
-0
Resolver.php
Core/Entities/Resolver.php
+3
-5
Activity.php
Entities/Activity.php
+1
-1
Image.php
Entities/Image.php
+2
-2
No files found.
Controllers/api/v2/feeds/scheduled.php
View file @
63c28906
...
...
@@ -67,6 +67,12 @@ class scheduled implements Interfaces\Api
'status'
=>
'success'
,
'count'
=>
$manager
->
getScheduledCount
([
'container_guid'
=>
$container_guid
,
'type'
=>
$type
])
]);
default
:
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'Invalid type'
,
]);
}
$hardLimit
=
5000
;
...
...
This diff is collapsed.
Click to expand it.
Core/Blogs/Delegates/TimeCreatedDelegate.php
View file @
63c28906
...
...
@@ -23,7 +23,7 @@ class TimeCreatedDelegate
}
/**
* Validates time_created date and set it to activity
* Validates time_created date and set
s
it to activity
* @param $entity
* @param string $time_created
* @return bool
...
...
This diff is collapsed.
Click to expand it.
Core/Entities/Delegates/FilterEntitiesDelegate.php
0 → 100644
View file @
63c28906
<?php
/**
* ResolverDelegate.
*
* @author juanmsolaro
*/
namespace
Minds\Core\Entities\Delegates
;
use
Minds\Core\Security\ACL
;
use
Minds\Entities\User
;
class
FilterEntitiesDelegate
{
/** @var ACL */
protected
$acl
;
/** @var User */
protected
$user
;
protected
$time
;
public
function
__construct
(
$user
,
$time
,
$acl
=
null
)
{
$this
->
acl
=
$acl
?:
ACL
::
_
();
$this
->
user
=
$user
;
$this
->
time
=
$time
;
}
/**
* Filter entities by read rights and write rights for scheduled activities, images, videos or blogs
* @param array $entities
* @return array
*/
public
function
filter
(
$entities
)
{
return
array_values
(
array_filter
(
$entities
,
function
(
$entity
)
{
$filterByScheduled
=
false
;
if
(
$this
->
shouldFilterScheduled
(
$entity
->
getType
()))
{
$filterByScheduled
=
!
ACL
::
_
()
->
write
(
$entity
,
$this
->
user
)
||
!
(
$entity
->
getTimeCreated
()
<=
$this
->
time
);
}
return
$this
->
acl
->
read
(
$entity
,
$this
->
user
)
&&
!
$filterByScheduled
;
}));
}
private
function
shouldFilterScheduled
(
$type
)
{
return
$type
==
'activity'
||
$type
==
'blog'
||
$type
==
'video'
||
$type
==
'image'
;
}
}
This diff is collapsed.
Click to expand it.
Core/Entities/Resolver.php
View file @
63c28906
...
...
@@ -12,6 +12,7 @@ use Minds\Core\Entities\Delegates\BoostGuidResolverDelegate;
use
Minds\Core\Entities\Delegates\CommentGuidResolverDelegate
;
use
Minds\Core\Entities\Delegates\EntityGuidResolverDelegate
;
use
Minds\Core\Entities\Delegates\ResolverDelegate
;
use
Minds\Core\Entities\Delegates\FilterEntitiesDelegate
;
use
Minds\Core\Security\ACL
;
use
Minds\Entities\User
;
...
...
@@ -128,11 +129,8 @@ class Resolver
});
// Filter out forbidden entities
$sorted
=
array_filter
(
$sorted
,
function
(
$entity
)
{
return
$this
->
acl
->
read
(
$entity
,
$this
->
user
);
//&& !Flags::shouldFail($entity);
});
$filterDelegate
=
new
FilterEntitiesDelegate
(
$this
->
user
,
time
(),
$this
->
acl
);
$sorted
=
$filterDelegate
->
filter
(
$sorted
);
//
...
...
This diff is collapsed.
Click to expand it.
Entities/Activity.php
View file @
63c28906
...
...
@@ -219,7 +219,7 @@ class Activity extends Entity
'ephemeral'
,
'hide_impressions'
,
'pinned'
,
'time_sent'
'time_sent'
,
]);
}
...
...
This diff is collapsed.
Click to expand it.
Entities/Image.php
View file @
63c28906
...
...
@@ -192,7 +192,7 @@ class Image extends File
'width'
,
'height'
,
'gif'
,
'time_sent'
'time_sent'
,
]);
}
...
...
@@ -281,7 +281,7 @@ class Image extends File
'mature'
,
'boost_rejection_reason'
,
'rating'
,
'time_sent'
'time_sent'
,
];
foreach
(
$allowed
as
$field
)
{
...
...
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