Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use App\Http\Utils\EpochCellFormatter;
use App\Jobs\Emails\InviteAttendeeTicketEditionMail;
use App\Jobs\Emails\SummitAttendeeAllTicketsEditionEmail;
use App\Jobs\Emails\SummitAttendeeRegistrationIncompleteReminderEmail;
use App\Jobs\Emails\SummitAttendeeTicketRegenerateHashEmail;
use App\Jobs\SynchAllAttendeesStatus;
use App\ModelSerializers\SerializerUtils;
Expand Down Expand Up @@ -847,7 +848,8 @@ public function send($summit_id)
'email_flow_event' => 'required|string|in:' . join(',', [
SummitAttendeeTicketRegenerateHashEmail::EVENT_SLUG,
InviteAttendeeTicketEditionMail::EVENT_SLUG,
SummitAttendeeAllTicketsEditionEmail::EVENT_SLUG
SummitAttendeeAllTicketsEditionEmail::EVENT_SLUG,
SummitAttendeeRegistrationIncompleteReminderEmail::EVENT_SLUG
]),
'attendees_ids' => 'sometimes|int_array',
]);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php namespace App\Jobs\Emails;

/**
* Copyright 2020 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use models\summit\SummitAttendee;

/**
* Class SummitAttendeeRegistrationIncompleteReminderEmail
* @package App\Jobs\Emails
*/
class SummitAttendeeRegistrationIncompleteReminderEmail extends AbstractSummitAttendeeTicketEmail
{
/**
* SummitAttendeeRegistrationIncompleteReminderEmail constructor.
* @param SummitAttendee $attendee
*/
public function __construct(SummitAttendee $attendee)
{
$payload = [];
$payload['owner_full_name'] = $attendee->getFullName();
$payload['owner_company'] = $attendee->getCompanyName();
$payload['owner_email'] = $attendee->getEmail();

if(empty($payload['owner_full_name'])){
$payload['owner_full_name'] = $payload['owner_email'];
}

$summit = $attendee->getSummit();

$payload['summit_name'] = $summit->getName();
$payload['summit_logo'] = $summit->getLogoUrl();
$payload['summit_virtual_site_url'] = $summit->getVirtualSiteUrl();
$payload['summit_marketing_site_url'] = $summit->getMarketingSiteUrl();

$base_url = Config::get("registration.dashboard_base_url", null);
if (empty($base_url))
throw new \InvalidArgumentException("missing dashboard_base_url value");

$back_url = Config::get("registration.dashboard_back_url", null);
if (empty($back_url))
throw new \InvalidArgumentException("missing dashboard_back_url value");

$payload['manage_orders_url'] = sprintf($back_url, $base_url);

$support_email = $summit->getSupportEmail();
$payload['support_email'] = !empty($support_email) ? $support_email: Config::get("registration.support_email", null);

if (empty($payload['support_email']))
throw new \InvalidArgumentException("missing support_email value");

$template_identifier = $this->getEmailTemplateIdentifierFromEmailEvent($summit);
Log::debug(sprintf("SummitAttendeeRegistrationIncompleteReminderEmail::__construct payload %s template %s",
json_encode($payload), $template_identifier));

parent::__construct($payload, $template_identifier, $payload['owner_email'] );
}

protected function getEmailEventSlug(): string
{
return self::EVENT_SLUG;
}

// metadata
const EVENT_SLUG = 'SUMMIT_REGISTRATION_INCOMPLETE_ATTENDEE_REMINDER';
const EVENT_NAME = 'SUMMIT_REGISTRATION_INCOMPLETE_ATTENDEE_REMINDER';
const DEFAULT_TEMPLATE = 'SUMMIT_REGISTRATION_INCOMPLETE_ATTENDEE_REMINDER';
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use App\Jobs\Emails\InviteAttendeeTicketEditionMail;
use App\Jobs\Emails\SummitAttendeeAllTicketsEditionEmail;
use App\Jobs\Emails\SummitAttendeeRegistrationIncompleteReminderEmail;
use App\Jobs\Emails\SummitAttendeeTicketRegenerateHashEmail;

/**
Expand All @@ -33,6 +34,8 @@ public function build(String $flow_event): ?AbstractEmailAction {
return new SummitAttendeeTicketEmailStrategy($flow_event);
case SummitAttendeeAllTicketsEditionEmail::EVENT_SLUG:
return new SummitAttendeeAllCurrentTicketsEmailStrategy($flow_event);
case SummitAttendeeRegistrationIncompleteReminderEmail::EVENT_SLUG:
return new SummitAttendeeRegistrationIncompleteReminderStrategy($flow_event);
default:
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php namespace App\Services\Model\Strategies\EmailActions;
/**
* Copyright 2022 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

use App\Jobs\Emails\SummitAttendeeRegistrationIncompleteReminderEmail;
use Illuminate\Support\Facades\Log;
use models\summit\SummitAttendee;

class SummitAttendeeRegistrationIncompleteReminderStrategy extends AbstractEmailAction
{
/**
* SummitAttendeeRegistrationIncompleteReminderStrategy constructor.
* @param String $flow_event
*/
public function __construct(String $flow_event)
{
parent::__construct($flow_event);
}

public function process(SummitAttendee $attendee)
{
if (!$attendee->isComplete()) {
Log::debug
(
sprintf
(
"SummitAttendeeRegistrationIncompleteReminderStrategy::sending reminder to attendee %s - flow event %s",
$attendee->getEmail(),
$this->flow_event
)
);
SummitAttendeeRegistrationIncompleteReminderEmail::dispatch($attendee);
} else {
Log::debug
(
sprintf
(
"SummitAttendeeRegistrationIncompleteReminderStrategy::nothing to send due to attendee (%s) status is complete",
$attendee->getEmail()
)
);
}
}
}
60 changes: 60 additions & 0 deletions database/migrations/model/Version20220216144229.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php namespace Database\Migrations\Model;
/**
* Copyright 2022 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use App\Jobs\Emails\SummitAttendeeRegistrationIncompleteReminderEmail;
use App\Models\Foundation\Summit\EmailFlows\SummitEmailFlowType;
use Database\Seeders\SummitEmailFlowTypeSeeder;
use Doctrine\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema as Schema;
use Illuminate\Support\Facades\DB;
use LaravelDoctrine\ORM\Facades\Registry;
use models\utils\SilverstripeBaseModel;
/**
* Class Version20220216144229
* @package Database\Migrations\Model
*/
class Version20220216144229 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
DB::setDefaultConnection("model");
$em = Registry::getManager(SilverstripeBaseModel::EntityManager);
$repository = $em->getRepository(SummitEmailFlowType::class);
$flow = $repository->findOneBy([
"name" => "Registration"
]);
SummitEmailFlowTypeSeeder::createEventsTypes(
[
[
'name' => SummitAttendeeRegistrationIncompleteReminderEmail::EVENT_NAME,
'slug' => SummitAttendeeRegistrationIncompleteReminderEmail::EVENT_SLUG,
'default_email_template' => SummitAttendeeRegistrationIncompleteReminderEmail::DEFAULT_TEMPLATE
]
],
$flow
);
$em->persist($flow);
$em->flush();
}

/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{

}
}
47 changes: 47 additions & 0 deletions database/migrations/model/Version20220218124421.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php namespace Database\Migrations\Model;
/**
* Copyright 2022 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Doctrine\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema as Schema;
use LaravelDoctrine\ORM\Facades\Registry;
use models\summit\Summit;
use models\utils\SilverstripeBaseModel;
/**
* Class Version20220218124421
* @package Database\Migrations\Model
*/
class Version20220218124421 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$em = Registry::getManager(SilverstripeBaseModel::EntityManager);
$repository = $em->getRepository(Summit::class);
$summits = $repository->findAll();
foreach($summits as $summit){
$summit->seedDefaultEmailFlowEvents();
$em->persist($summit);
}
$em->flush();
}

/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{

}
}
7 changes: 7 additions & 0 deletions database/seeders/SummitEmailFlowTypeSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/

use App\Jobs\Emails\SummitAttendeeRegistrationIncompleteReminderEmail;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use App\Models\Foundation\Summit\EmailFlows\SummitEmailFlowType;
Expand Down Expand Up @@ -129,6 +131,11 @@ public static function seed(){
'slug' => SummitTicketReminderEmail::EVENT_SLUG,
'default_email_template' => SummitTicketReminderEmail::DEFAULT_TEMPLATE
],
[
'name' => SummitAttendeeRegistrationIncompleteReminderEmail::EVENT_NAME,
'slug' => SummitAttendeeRegistrationIncompleteReminderEmail::EVENT_SLUG,
'default_email_template' => SummitAttendeeRegistrationIncompleteReminderEmail::DEFAULT_TEMPLATE
],
// refunds
[
'name' => SummitOrderRefundAccepted::EVENT_NAME,
Expand Down
13 changes: 13 additions & 0 deletions tests/AttendeeServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
**/

use App\Jobs\Emails\SummitAttendeeAllTicketsEditionEmail;
use App\Jobs\Emails\SummitAttendeeRegistrationIncompleteReminderEmail;
use App\Models\Foundation\Main\IGroup;
use App\Services\Model\IAttendeeService;
use Illuminate\Support\Facades\App;
Expand Down Expand Up @@ -71,4 +72,16 @@ public function testSendAllAttendeeTicketsByAttendeeIds() {

$service->send(self::$summit->getId(), $payload);
}

public function testSendRegistrationIncompleteReminderByAttendeeIds() {

$service = App::make(IAttendeeService::class);

$payload = [
"email_flow_event" => SummitAttendeeRegistrationIncompleteReminderEmail::EVENT_SLUG,
"attendees_ids" => [self::$summit->getAttendees()[0]->getId()],
];

$service->send(self::$summit->getId(), $payload);
}
}