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:
parent
54140bf859
commit
2d69b4a18d
@ -68,6 +68,53 @@ class DefaultController extends AbstractController {
|
||||
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(
|
||||
* path = "/poll",
|
||||
|
@ -53,162 +53,178 @@ class Owner {
|
||||
* @ORM\Column(type="datetime" , options={"default"="CURRENT_TIMESTAMP"})
|
||||
*/
|
||||
private $createdAt;
|
||||
/**
|
||||
* @ORM\Column(type="requested_polls_date" , options={"default"="CURRENT_TIMESTAMP"},nullable=true)
|
||||
*/
|
||||
private $requestedPollsDate;
|
||||
|
||||
public function __construct() {
|
||||
$this->polls = new ArrayCollection();
|
||||
$this->comments = new ArrayCollection();
|
||||
$this->stackOfVotes = new ArrayCollection();
|
||||
$this->setCreatedAt( new \DateTime() );
|
||||
$this->setModifierToken( uniqid() );
|
||||
}
|
||||
$this->polls = new ArrayCollection();
|
||||
$this->comments = new ArrayCollection();
|
||||
$this->stackOfVotes = new ArrayCollection();
|
||||
$this->setCreatedAt( new \DateTime() );
|
||||
$this->setModifierToken( uniqid() );
|
||||
}
|
||||
|
||||
|
||||
public function getId(): ?int {
|
||||
return $this->id;
|
||||
}
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getEmail(): ?string {
|
||||
return $this->email;
|
||||
}
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setEmail( string $email ): self {
|
||||
$this->email = $email;
|
||||
$this->email = $email;
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPseudo(): ?string {
|
||||
return $this->pseudo;
|
||||
}
|
||||
return $this->pseudo;
|
||||
}
|
||||
|
||||
public function setPseudo( string $pseudo ): self {
|
||||
$this->pseudo = $pseudo;
|
||||
$this->pseudo = $pseudo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Poll[]
|
||||
*/
|
||||
public function getPolls(): Collection {
|
||||
return $this->polls;
|
||||
}
|
||||
return $this->polls;
|
||||
}
|
||||
|
||||
public function addPoll( Poll $poll ): self {
|
||||
if ( ! $this->polls->contains( $poll ) ) {
|
||||
$this->polls[] = $poll;
|
||||
$poll->setOwner( $this );
|
||||
}
|
||||
if ( ! $this->polls->contains( $poll ) ) {
|
||||
$this->polls[] = $poll;
|
||||
$poll->setOwner( $this );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removePoll( Poll $poll ): self {
|
||||
if ( $this->polls->contains( $poll ) ) {
|
||||
$this->polls->removeElement( $poll );
|
||||
// set the owning side to null (unless already changed)
|
||||
if ( $poll->getOwner() === $this ) {
|
||||
$poll->setOwner( null );
|
||||
}
|
||||
}
|
||||
if ( $this->polls->contains( $poll ) ) {
|
||||
$this->polls->removeElement( $poll );
|
||||
// set the owning side to null (unless already changed)
|
||||
if ( $poll->getOwner() === $this ) {
|
||||
$poll->setOwner( null );
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Comment[]
|
||||
*/
|
||||
public function getComments(): Collection {
|
||||
return $this->comments;
|
||||
}
|
||||
return $this->comments;
|
||||
}
|
||||
|
||||
public function addText( Comment $text ): self {
|
||||
if ( ! $this->comments->contains( $text ) ) {
|
||||
$this->comments[] = $text;
|
||||
$text->setOwner( $this );
|
||||
}
|
||||
if ( ! $this->comments->contains( $text ) ) {
|
||||
$this->comments[] = $text;
|
||||
$text->setOwner( $this );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeText( Comment $text ): self {
|
||||
if ( $this->comments->contains( $text ) ) {
|
||||
$this->comments->removeElement( $text );
|
||||
// set the owning side to null (unless already changed)
|
||||
if ( $text->getOwner() === $this ) {
|
||||
$text->setOwner( null );
|
||||
}
|
||||
}
|
||||
if ( $this->comments->contains( $text ) ) {
|
||||
$this->comments->removeElement( $text );
|
||||
// set the owning side to null (unless already changed)
|
||||
if ( $text->getOwner() === $this ) {
|
||||
$text->setOwner( null );
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|StackOfVotes[]
|
||||
*/
|
||||
public function getStackOfVotes(): Collection {
|
||||
return $this->stackOfVotes;
|
||||
}
|
||||
return $this->stackOfVotes;
|
||||
}
|
||||
|
||||
public function addStackOfVote( StackOfVotes $stackOfVote ): self {
|
||||
if ( ! $this->stackOfVotes->contains( $stackOfVote ) ) {
|
||||
$this->stackOfVotes[] = $stackOfVote;
|
||||
$stackOfVote->setOwner( $this );
|
||||
}
|
||||
if ( ! $this->stackOfVotes->contains( $stackOfVote ) ) {
|
||||
$this->stackOfVotes[] = $stackOfVote;
|
||||
$stackOfVote->setOwner( $this );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeStackOfVote( StackOfVotes $stackOfVote ): self {
|
||||
if ( $this->stackOfVotes->contains( $stackOfVote ) ) {
|
||||
$this->stackOfVotes->removeElement( $stackOfVote );
|
||||
// set the owning side to null (unless already changed)
|
||||
if ( $stackOfVote->getOwner() === $this ) {
|
||||
$stackOfVote->setOwner( null );
|
||||
}
|
||||
}
|
||||
if ( $this->stackOfVotes->contains( $stackOfVote ) ) {
|
||||
$this->stackOfVotes->removeElement( $stackOfVote );
|
||||
// set the owning side to null (unless already changed)
|
||||
if ( $stackOfVote->getOwner() === $this ) {
|
||||
$stackOfVote->setOwner( null );
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getModifierToken(): ?string {
|
||||
return $this->modifierToken;
|
||||
}
|
||||
return $this->modifierToken;
|
||||
}
|
||||
|
||||
public function setModifierToken( string $modifierToken ): self {
|
||||
$this->modifierToken = $modifierToken;
|
||||
$this->modifierToken = $modifierToken;
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addComment( Comment $comment ): self {
|
||||
if ( ! $this->comments->contains( $comment ) ) {
|
||||
$this->comments[] = $comment;
|
||||
$comment->setOwner( $this );
|
||||
}
|
||||
if ( ! $this->comments->contains( $comment ) ) {
|
||||
$this->comments[] = $comment;
|
||||
$comment->setOwner( $this );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeComment( Comment $comment ): self {
|
||||
if ( $this->comments->contains( $comment ) ) {
|
||||
$this->comments->removeElement( $comment );
|
||||
// set the owning side to null (unless already changed)
|
||||
if ( $comment->getOwner() === $this ) {
|
||||
$comment->setOwner( null );
|
||||
}
|
||||
}
|
||||
if ( $this->comments->contains( $comment ) ) {
|
||||
$this->comments->removeElement( $comment );
|
||||
// set the owning side to null (unless already changed)
|
||||
if ( $comment->getOwner() === $this ) {
|
||||
$comment->setOwner( null );
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): ?\DateTimeInterface {
|
||||
return $this->createdAt;
|
||||
}
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function setCreatedAt( \DateTimeInterface $createdAt ): self {
|
||||
$this->createdAt = $createdAt;
|
||||
$this->createdAt = $createdAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRequestedPollsDate()
|
||||
{
|
||||
return $this->requestedPollsDate;
|
||||
}
|
||||
|
||||
public function setRequestedPollsDate($requestedPollsDate): self
|
||||
{
|
||||
$this->requestedPollsDate = $requestedPollsDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
14
src/templates/owner-list.html.twig
Normal file
14
src/templates/owner-list.html.twig
Normal 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
|
Loading…
Reference in New Issue
Block a user