1
0
mirror of https://framagit.org/tykayn/date-poll-api synced 2023-08-25 08:23:11 +02:00

start email to owner listing polls

This commit is contained in:
Baptiste Lemoine 2020-01-02 16:34:23 +01:00
parent 54140bf859
commit 2d69b4a18d
3 changed files with 182 additions and 105 deletions

View File

@ -68,6 +68,53 @@ class DefaultController extends AbstractController {
200 ); 200 );
} }
/**
* @Get(
* path = "/send-polls-to-user/{email}",
* name = "send_user_polls"
* )
*/
public function sendPollsToUser( $email ) {
$repository = $this->getDoctrine()->getRepository( Owner::class );
$founduser = $repository->findOneBy( [ 'email' => $email ] );
if ( $founduser ) {
$polls = $founduser->getPolls();
$message = ( new \Swift_Message( 'Framadate - mes sondages' ) )
->setFrom( 'ne-pas-repondre@framdate-api.cipherbliss.com' )
->setTo( $founduser->getEmail() )
->setBody(
$this->renderView(
// templates/hello/email.txt.twig
'owner-list.html.twig',
[
'owner' => $founduser,
'polls' => $polls,
]
)
);
$mailer->send( $message );
return $this->json( [
'message' => 'here are your polls, ' . $email,
'data' => 'email was sent with a list of ' . count( $polls ) . ' polls',
],
200 );
} else {
return $this->json( [
'message' => 'no user found for email ' . $email,
'data' => '',
],
400 );
}
// find user by email
// send email
// user not found case
}
/** /**
* @Post( * @Post(
* path = "/poll", * path = "/poll",

View File

@ -53,6 +53,10 @@ class Owner {
* @ORM\Column(type="datetime" , options={"default"="CURRENT_TIMESTAMP"}) * @ORM\Column(type="datetime" , options={"default"="CURRENT_TIMESTAMP"})
*/ */
private $createdAt; private $createdAt;
/**
* @ORM\Column(type="requested_polls_date" , options={"default"="CURRENT_TIMESTAMP"},nullable=true)
*/
private $requestedPollsDate;
public function __construct() { public function __construct() {
$this->polls = new ArrayCollection(); $this->polls = new ArrayCollection();
@ -209,6 +213,18 @@ class Owner {
public function setCreatedAt( \DateTimeInterface $createdAt ): self { public function setCreatedAt( \DateTimeInterface $createdAt ): self {
$this->createdAt = $createdAt; $this->createdAt = $createdAt;
return $this;
}
public function getRequestedPollsDate()
{
return $this->requestedPollsDate;
}
public function setRequestedPollsDate($requestedPollsDate): self
{
$this->requestedPollsDate = $requestedPollsDate;
return $this; return $this;
} }
} }

View File

@ -0,0 +1,14 @@
{#[Framadate][Réservé à l'auteur] Sondage: TESSSSSSSSSST#}
Voici la liste des {{ polls|length }} sondages Framadate que vous avez créé.
<hr>
<ul>
{% for p in polls %}
<li>
{{ p.title }}
{{ p.adminKey }}
</li>
{% endfor %}
</ul>
Merci de votre confiance.
Framadate