mirror of
https://framagit.org/tykayn/date-poll-api
synced 2023-08-25 08:23:11 +02:00
add symfony profiling, and spool for emails
This commit is contained in:
parent
64fd83caa2
commit
a034f59a90
2
.env
2
.env
@ -38,7 +38,7 @@ DATABASE_URL=mysql://framadate-admin:framadate-admin-password@127.0.0.1:3306/fra
|
||||
# Delivery is disabled by default via "null://localhost"
|
||||
MAILER_URL=sendmail://YOUR_WEBSITE
|
||||
# set the support email who will answer users in case of emergency
|
||||
SUPPORT_EMAIL=YOUR_EMAIL
|
||||
SUPPORT_EMAIL=support-framadate@YOUR_WEBSITE
|
||||
###< symfony/swiftmailer-bundle ###
|
||||
|
||||
###> nelmio/cors-bundle ###
|
||||
|
@ -64,7 +64,9 @@
|
||||
"require-dev": {
|
||||
"doctrine/doctrine-fixtures-bundle": "^3.4",
|
||||
"symfony/debug-bundle": "5.2.*",
|
||||
"symfony/maker-bundle": "^1.30"
|
||||
"symfony/maker-bundle": "^1.30",
|
||||
"symfony/stopwatch": "^5.2",
|
||||
"symfony/web-profiler-bundle": "^5.2"
|
||||
},
|
||||
"scripts": {
|
||||
"auto-scripts": {
|
||||
|
80
composer.lock
generated
80
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "9a37fb1f1119669bc5d2ebb272491699",
|
||||
"content-hash": "104b8c116015bbc6f7f3efa3d0618a90",
|
||||
"packages": [
|
||||
{
|
||||
"name": "composer/package-versions-deprecated",
|
||||
@ -6837,6 +6837,84 @@
|
||||
}
|
||||
],
|
||||
"time": "2021-03-23T13:53:38+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/web-profiler-bundle",
|
||||
"version": "v5.2.8",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/web-profiler-bundle.git",
|
||||
"reference": "68aea5b0ca1328c2a1ae3df04cce50302a5106f9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/web-profiler-bundle/zipball/68aea5b0ca1328c2a1ae3df04cce50302a5106f9",
|
||||
"reference": "68aea5b0ca1328c2a1ae3df04cce50302a5106f9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2.5",
|
||||
"symfony/config": "^4.4|^5.0",
|
||||
"symfony/framework-bundle": "^5.1",
|
||||
"symfony/http-kernel": "^5.2",
|
||||
"symfony/routing": "^4.4|^5.0",
|
||||
"symfony/twig-bundle": "^4.4|^5.0",
|
||||
"twig/twig": "^2.13|^3.0.4"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/dependency-injection": "<5.2",
|
||||
"symfony/form": "<4.4",
|
||||
"symfony/messenger": "<4.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/browser-kit": "^4.4|^5.0",
|
||||
"symfony/console": "^4.4|^5.0",
|
||||
"symfony/css-selector": "^4.4|^5.0",
|
||||
"symfony/stopwatch": "^4.4|^5.0"
|
||||
},
|
||||
"type": "symfony-bundle",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Bundle\\WebProfilerBundle\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Provides a development tool that gives detailed information about the execution of any request",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/web-profiler-bundle/tree/v5.2.8"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-05-11T14:36:09+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
|
@ -13,4 +13,5 @@ return [
|
||||
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
|
||||
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
|
||||
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true],
|
||||
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
|
||||
];
|
||||
|
6
config/packages/dev/web_profiler.yaml
Normal file
6
config/packages/dev/web_profiler.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
web_profiler:
|
||||
toolbar: true
|
||||
intercept_redirects: false
|
||||
|
||||
framework:
|
||||
profiler: { only_exceptions: false }
|
11
config/packages/prod/mailer.yml
Normal file
11
config/packages/prod/mailer.yml
Normal file
@ -0,0 +1,11 @@
|
||||
#SUPPORT_EMAIL: '%env(SUPPORT_EMAIL)%'
|
||||
# config/packages/dev/mailer.yaml
|
||||
framework:
|
||||
mailer:
|
||||
envelope:
|
||||
sender: 'fabien@example.com'
|
||||
recipients: ['foo@example.com', 'bar@example.com']
|
||||
headers:
|
||||
from: '%env(SUPPORT_EMAIL)%'
|
||||
bcc: 'baz@example.com'
|
||||
X-Custom-Header: 'foobar'
|
@ -1,3 +1,5 @@
|
||||
swiftmailer:
|
||||
url: '%env(MAILER_URL)%'
|
||||
spool: { type: 'memory' }
|
||||
spool:
|
||||
type: 'file'
|
||||
path: /var/www/html/date-poll-api/var/email/spool
|
||||
|
6
config/packages/test/web_profiler.yaml
Normal file
6
config/packages/test/web_profiler.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
web_profiler:
|
||||
toolbar: false
|
||||
intercept_redirects: false
|
||||
|
||||
framework:
|
||||
profiler: { collect: false }
|
7
config/routes/dev/web_profiler.yaml
Normal file
7
config/routes/dev/web_profiler.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
web_profiler_wdt:
|
||||
resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml'
|
||||
prefix: /_wdt
|
||||
|
||||
web_profiler_profiler:
|
||||
resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml'
|
||||
prefix: /_profiler
|
@ -5,10 +5,13 @@ namespace App\Controller;
|
||||
use App\Entity\Owner;
|
||||
use App\Entity\Poll;
|
||||
use JMS\Serializer\Type\Exception\Exception;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Swift_Mailer;
|
||||
use Swift_Message;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Mailer\Exception\HttpTransportException;
|
||||
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
|
||||
|
||||
/**
|
||||
* sending emails controller
|
||||
*
|
||||
@ -51,7 +54,7 @@ class EmailsController extends AbstractController {
|
||||
*
|
||||
* @throws TransportExceptionInterface
|
||||
*/
|
||||
public function sendMailWithVars( $config ) {
|
||||
public function sendMailWithVars( $config) {
|
||||
|
||||
if ( ! isset( $config[ 'poll' ] ) ) {
|
||||
$config[ 'poll' ] = new Poll();
|
||||
@ -82,14 +85,22 @@ class EmailsController extends AbstractController {
|
||||
$message = ( new Swift_Message( $config[ 'title' ] ) )
|
||||
->setContentType( "text/html" )
|
||||
->setCharset( 'UTF-8' )
|
||||
->setFrom( [ 'ne-pas-repondre@framadate-api.cipherbliss.com'] )
|
||||
->setFrom( [ 'ne-pas-repondre@framadate-api.cipherbliss.com' ] )
|
||||
->setTo( [ $config[ 'owner' ]->getEmail() ] )
|
||||
->setBody( $htmlbody, 'text/html' );
|
||||
|
||||
|
||||
// Send the message
|
||||
$numSent = $this->mail_service->send( $message );
|
||||
$this->numSent = $numSent;
|
||||
try {
|
||||
$numSent = $this->mail_service->send( $message );
|
||||
|
||||
$this->numSent = $numSent;
|
||||
} catch ( TransportExceptionInterface $err ) {
|
||||
// some error prevented the email sending; display an
|
||||
// error message or try to resend the message
|
||||
|
||||
throw $err;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ use FOS\RestBundle\Controller\Annotations\Post;
|
||||
use FOS\RestBundle\Controller\Annotations\Put;
|
||||
use FOS\RestBundle\Controller\Annotations\Route;
|
||||
use JMS\Serializer\SerializerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Swift_Mailer;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@ -130,7 +131,7 @@ class PollController extends EmailsController {
|
||||
*
|
||||
* @return JsonResponse|Response
|
||||
*/
|
||||
function getOwnerPolls( $owner_email ) {
|
||||
function getOwnerPolls( $owner_email , LoggerInterface $logger ) {
|
||||
$repository = $this->getDoctrine()->getRepository( Owner::class );
|
||||
$owner = $repository->findOneByEmail( $owner_email );
|
||||
if ( ! $owner ) {
|
||||
@ -144,7 +145,7 @@ class PollController extends EmailsController {
|
||||
$pollsDisplay[] = $p->displayForAdmin();
|
||||
}
|
||||
$mail_sent = $this->sendOwnerPollsAction( $owner );
|
||||
|
||||
$logger->info('getOwnerPolls : Email sent : '.$mail_sent);
|
||||
return $this->json( [ 'mail_sent' => $mail_sent ], $mail_sent ? 200 : 404 );
|
||||
// return $this->json(['owner' => $owner->displayForAdmin(), 'polls' => $pollsDisplay], 200);
|
||||
}
|
||||
@ -442,27 +443,6 @@ class PollController extends EmailsController {
|
||||
return $this->render( 'emails/creation-mail.html.twig',
|
||||
[ 'poll' => $foundPoll, 'owner' => $foundPoll->getOwner() ] );
|
||||
|
||||
|
||||
// if ( $foundOwner ) {
|
||||
// $sent = $this->sendOwnerPollsAction( $foundOwner );
|
||||
// if ( $sent ) {
|
||||
// $config = [
|
||||
// 'owner' => $foundOwner,
|
||||
// 'title' => $this->getParameter( 'WEBSITE_NAME' ) . ' | Mes sondages',
|
||||
// 'email_template' => 'emails/owner-list.html.twig',
|
||||
// ];
|
||||
// return $this->render( 'emails/owner-list.html.twig', $config );
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
// return $this->json( [ "message" => "test email sent to " . $foundOwner->getEmail() . "!" ], 200 );
|
||||
|
||||
// $this->sendMailWithVars( $config );
|
||||
|
||||
|
||||
// return $this->json( [ "message" => "user with this email was not found" ], 400 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
17
symfony.lock
17
symfony.lock
@ -350,6 +350,9 @@
|
||||
"symfony/polyfill-php80": {
|
||||
"version": "v1.22.1"
|
||||
},
|
||||
"symfony/profiler-pack": {
|
||||
"version": "v1.0.5"
|
||||
},
|
||||
"symfony/property-access": {
|
||||
"version": "v5.2.4"
|
||||
},
|
||||
@ -425,6 +428,20 @@
|
||||
"symfony/var-exporter": {
|
||||
"version": "v5.2.4"
|
||||
},
|
||||
"symfony/web-profiler-bundle": {
|
||||
"version": "3.3",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes",
|
||||
"branch": "master",
|
||||
"version": "3.3",
|
||||
"ref": "6bdfa1a95f6b2e677ab985cd1af2eae35d62e0f6"
|
||||
},
|
||||
"files": [
|
||||
"config/packages/dev/web_profiler.yaml",
|
||||
"config/packages/test/web_profiler.yaml",
|
||||
"config/routes/dev/web_profiler.yaml"
|
||||
]
|
||||
},
|
||||
"symfony/yaml": {
|
||||
"version": "v5.2.5"
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user