Compare commits

..

3 commits

Author SHA1 Message Date
0d777d214c
use secure_url() 2024-06-09 22:29:37 +02:00
1d8fb6b407
build: prune -a 2024-06-09 22:29:25 +02:00
98dc469772
fix: pass `` to email 2024-06-09 22:29:04 +02:00
3 changed files with 24 additions and 13 deletions

View file

@ -24,17 +24,24 @@ class Digest extends Mailable
/** /**
* The current trip locations as a JSON object. * The current trip locations as a JSON object.
* *
* @var string * @var obj
*/ */
public $locations; public $locations;
/** /**
* The current trip checkins as a JSON object. * The current trip checkins as a JSON object.
* *
* @var string * @var obj
*/ */
public $checkinsList; public $checkinsList;
/**
* The current trip object.
*
* @var obj
*/
public $trip;
/** /**
* Create a new message instance. * Create a new message instance.
* *
@ -45,7 +52,7 @@ class Digest extends Mailable
public function __construct(string $digest_type, string $trip_id) public function __construct(string $digest_type, string $trip_id)
{ {
$this->digest_type = $digest_type; $this->digest_type = $digest_type;
$trip = (new TrackerController)->get_trip_data($trip_id); $this->trip = (new TrackerController)->get_trip_data($trip_id);
$cutoffDateTime = new DateTime(); $cutoffDateTime = new DateTime();
switch ($this->digest_type) { switch ($this->digest_type) {
@ -65,7 +72,7 @@ class Digest extends Mailable
} }
$this->checkinsList = array_filter( $this->checkinsList = array_filter(
$trip->checkins, $this->trip->checkins,
function ($elem) use ($cutoffDateTime) { function ($elem) use ($cutoffDateTime) {
$elemDateTime = new DateTime($elem->created_at); $elemDateTime = new DateTime($elem->created_at);
return $elemDateTime > $cutoffDateTime; return $elemDateTime > $cutoffDateTime;
@ -80,7 +87,11 @@ class Digest extends Mailable
*/ */
public function build() public function build()
{ {
return $this->view('emails.digest') return $this->view(
->subject("track.bengoldsworthy.net ".ucwords($this->digest_type)." Digest"); 'emails.digest',
[
'trip' => $this->trip
]
)->subject("track.bengoldsworthy.net ".ucwords($this->digest_type)." Digest");
} }
} }

View file

@ -7,7 +7,7 @@
"deploy:public": "rsync --delete -rP public ovhvps:~/track", "deploy:public": "rsync --delete -rP public ovhvps:~/track",
"deploy:dependencies": "rsync --delete -rP vendor ovhvps:~/track", "deploy:dependencies": "rsync --delete -rP vendor ovhvps:~/track",
"deploy:full": "npm run deploy && npm run deploy:public && npm run deploy:dependencies && npm run deploy:finish", "deploy:full": "npm run deploy && npm run deploy:public && npm run deploy:dependencies && npm run deploy:finish",
"deploy:finish": "ssh ovhvps 'cd track && docker compose down && docker system prune -f && docker compose up -d --build'", "deploy:finish": "ssh ovhvps 'cd track && docker compose down && docker system prune -a -f && docker compose up -d --build'",
"lint": "npm run lint:php; npm run lint:css", "lint": "npm run lint:php; npm run lint:css",
"lint:fix": "npm run lint:php:fix; npm run lint:css:fix", "lint:fix": "npm run lint:php:fix; npm run lint:css:fix",
"lint:php": "./vendor/bin/phpcs", "lint:php": "./vendor/bin/phpcs",

View file

@ -11,11 +11,11 @@
$path = "/" . $trip_slug . "/" .$hasEmbed . "/" . $filepath[1]; $path = "/" . $trip_slug . "/" .$hasEmbed . "/" . $filepath[1];
$embed = '<video class="popup__video" controls>'; $embed = '<video class="popup__video" controls>';
$embed .= '<source src="' . url( $path ) . '" type="video/webm">'; $embed .= '<source src="' . secure_url( $path ) . '" type="video/webm">';
$embed .= '<p>Your client doesn\'t support HTML video. Here is a <a href="' . url( $path ) . '">link to the video</a> instead.</p>'; $embed .= '<p>Your client doesn\'t support HTML video. Here is a <a href="' . secure_url( $path ) . '">link to the video</a> instead.</p>';
$embed .= '</video>'; $embed .= '</video>';
if (isset($email)) { if (isset($email)) {
$embed .= '<p><i>If your email client doesn\'t support video embeds, here is a <a href="' . url( $path ) . '">link to the file</a> instead.</i></p>'; $embed .= '<p><i>If your email client doesn\'t support video embeds, here is a <a href="' . secure_url( $path ) . '">link to the file</a> instead.</i></p>';
} }
} else { } else {
$embed = '<p>[The video \'' . $filepath[1] . '\' has not yet been uploaded, try again later.]</p>'; $embed = '<p>[The video \'' . $filepath[1] . '\' has not yet been uploaded, try again later.]</p>';
@ -28,11 +28,11 @@
$path = "/" . $trip_slug . "/" .$hasEmbed . "/" . $filepath[1]; $path = "/" . $trip_slug . "/" .$hasEmbed . "/" . $filepath[1];
$embed = '<audio class="popup__audio" controls>'; $embed = '<audio class="popup__audio" controls>';
$embed .= '<source src="' . url( $path ) . '" type="audio/ogg">'; $embed .= '<source src="' . secure_url( $path ) . '" type="audio/ogg">';
$embed .= '<p>Download <a href="' . url( $path ) . '">OGG</a> audio.</p>'; $embed .= '<p>Download <a href="' . secure_url( $path ) . '">OGG</a> audio.</p>';
$embed .= '</audio>'; $embed .= '</audio>';
if (isset($email)) { if (isset($email)) {
$embed .= '<p><i>If your email client doesn\' support audio embeds, here is a <a href="' . url( $path ) . '">link to the file</a> instead.</i></p>'; $embed .= '<p><i>If your email client doesn\' support audio embeds, here is a <a href="' . secure_url( $path ) . '">link to the file</a> instead.</i></p>';
} }
} else { } else {
$embed = '<p>[The recording \'' . $filepath[1] . '\' has not yet been uploaded, try again later.]</p>'; $embed = '<p>[The recording \'' . $filepath[1] . '\' has not yet been uploaded, try again later.]</p>';