Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Dependency List
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
185
Issues
185
List
Boards
Labels
Service Desk
Milestones
Merge Requests
31
Merge Requests
31
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
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
adce7fc7
Commit
adce7fc7
authored
22 minutes ago
by
Mark Harding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(feat): july blogs email
parent
3785b65b
master
test/gitlab-ci
No related merge requests found
Pipeline
#73812163
passed with stages
in 9 minutes and 23 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
158 additions
and
0 deletions
+158
-0
WithBlogs.php
Core/Email/Batches/WithBlogs.php
+158
-0
No files found.
Core/Email/Batches/WithBlogs.php
0 → 100644
View file @
adce7fc7
<?php
namespace
Minds\Core\Email\Batches
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Security\ACL
;
use
Minds\Core\Email\Campaigns
;
use
Minds\Core\Email\EmailSubscribersIterator
;
use
Minds\Traits\MagicAttributes
;
class
WithBlogs
implements
EmailBatchInterface
{
use
MagicAttributes
;
/** @var Manager */
protected
$manager
;
/** @var Repository */
protected
$repository
;
/** @var EntitiesBuilder */
protected
$builder
;
/** @var string $offset */
protected
$offset
;
/** @var string $offset */
protected
$templatePath
;
/** @var string $subject */
protected
$subject
;
public
function
__construct
(
$manager
=
null
,
$trendingRepository
=
null
,
$builder
=
null
)
{
$this
->
manager
=
$manager
?:
Di
::
_
()
->
get
(
'Email\Manager'
);
$this
->
repository
=
$trendingRepository
?:
Di
::
_
()
->
get
(
'Trending\Repository'
);
$this
->
builder
=
$builder
?:
Di
::
_
()
->
get
(
'EntitiesBuilder'
);
}
public
function
setDryRun
(
$dry
)
{
return
$this
;
}
/**
* @param string $offset
*
* @return Catchup
*/
public
function
setOffset
(
$offset
)
{
$this
->
offset
=
$offset
;
return
$this
;
}
/**
* @param string $templatePath
*
* @return Catchup
*/
public
function
setTemplateKey
(
$template
)
{
$this
->
templatePath
=
$template
;
return
$this
;
}
/**
* @param string $subject
*
* @return Catchup
*/
public
function
setSubject
(
$subject
)
{
$this
->
subject
=
$subject
;
return
$this
;
}
/**
* @throws \Exception
*/
public
function
run
()
{
if
(
!
$this
->
templatePath
||
$this
->
templatePath
==
''
)
{
// throw new \Exception('You must set the templatePath');
}
if
(
!
$this
->
subject
||
$this
->
subject
==
''
)
{
// throw new \Exception('You must set the subject');
}
$iterator
=
new
EmailSubscribersIterator
();
$iterator
->
setCampaign
(
'with'
)
->
setTopic
(
'posts_missed_since_login'
)
->
setValue
(
true
)
->
setOffset
(
$this
->
offset
);
$blogs
=
$this
->
getTrendingBlogs
();
$i
=
0
;
foreach
(
$iterator
as
$user
)
{
$user
=
new
\Minds\Entities\User
(
'mark'
);
++
$i
;
echo
"
\n
[
$i
]:
$user->guid
(
$iterator->offset
)"
;
//if ($user->getTimeCreated() > strtotime('-28 days ago')) {
// echo "[done]";
// return true;
//}
$campaign
=
new
Campaigns\WithBlogs
();
$campaign
->
setUser
(
$user
)
->
setTemplateKey
(
$this
->
templatePath
)
->
setSubject
(
$this
->
subject
)
->
setBlogs
(
$blogs
)
->
send
();
echo
' sent'
;
exit
;
}
}
private
function
getTrendingBlogs
()
{
ACL
::
$ignore
=
true
;
/*$result = $this->repository->getList([
'type' => 'blogs',
'limit' => 10
]);
if (!$result || !$result['guids'] || count($result['guids']) === 0) {
return [];
}
ksort($result['guids']);
$options['guids'] = $result['guids'];*/
$options
[
'guids'
]
=
[
'998738105104236544'
,
'999467832663445504'
,
'966409629405708288'
,
'993006058717818880'
,
'973946575102472192'
,
'996468067362422784'
,
'993621806187380736'
,
'971156445331410944'
,
'983472046539116544'
,
'952732651199864832'
,
];
$blogs
=
$this
->
builder
->
get
(
array_merge
([
'subtype'
=>
'blog'
,
],
$options
));
return
$blogs
;
}
}
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