Skip to content

Commit

Permalink
Bugfix/instagram daily schedule (#161)
Browse files Browse the repository at this point in the history
* instagram text now always in cet timezone no matter of users timezone

* add repeats playlist to instagram text

* add text that all times are in cet

* adjust reply_to for automated email
  • Loading branch information
antiantivirus authored Jan 14, 2025
1 parent d9a9b17 commit ae5a9e6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
11 changes: 4 additions & 7 deletions lib/contentful/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,15 +487,10 @@ function isPublished(entity) {

export async function getInstaInfo() {
const cetAdjustment = dayjs().tz("Europe/Berlin").utcOffset();
const start = Date.now();
const nowUTC = dayjs.utc();
const nowCET = nowUTC.add(cetAdjustment, "minutes");
const startOfDay = nowCET.subtract(5, "hour").startOf("day").add(5, "hours");
const startSchedule = startOfDay.toISOString();
const dayOfWeek = startOfDay.day();
// if (dayOfWeek == 6 || dayOfWeek == 0) {
// endScheduleAdjustment = 3;
// }
const endSchedule = startOfDay.add(1, "day").toISOString();

const scheduleQuery = /* GraphQL */ `
Expand All @@ -511,6 +506,7 @@ export async function getInstaInfo() {
items {
title
date
dateEnd
instagramHandles
}
}
Expand All @@ -524,9 +520,10 @@ export async function getInstaInfo() {
const instaInfo = extractCollection<CalendarShow>(res, "showCollection");

instaInfo.forEach((show, index) => {
show.date = dayjs(show.date)
.subtract(cetAdjustment, "minutes")
show.date = dayjs(show.date.slice(0, -1))
// .subtract(cetAdjustment, "minutes")
.format("HH:mm");
show.dateEnd = dayjs(show.dateEnd.slice(0, -1)).format("HH:mm");
show.title = show.title.replace("|", "—");
});

Expand Down
15 changes: 8 additions & 7 deletions lib/resend/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ const resend = new Resend(process.env.RESEND_API_KEY);
import { sendSlackMessage } from "../../lib/slack";
import dayjs from "dayjs";

const replyToEmails = [
"[email protected]",
"[email protected]",
];

export async function sendEmail(artist, show, severity) {
try {
const { data, error } = await resend.emails.send({
from: "Refuge Worldwide <[email protected]>",
to: artist.email,
subject: subject(severity),
reply_to: ["[email protected]", "[email protected]"],
reply_to: replyToEmails,
react: ShowSubmissionEmail({
userName: artist.name,
showDateStart: show.date,
Expand Down Expand Up @@ -46,10 +51,7 @@ export async function sendConfirmationEmail(show) {
to: artist.email,
subject:
"Show confirmation - " + dayjs(show.start).format("MMM YYYY"),
reply_to: [
"[email protected]",
"[email protected]",
],
reply_to: replyToEmails,
react: ShowSubmissionEmail({
userName: artist.label,
showDateStart: show.start,
Expand Down Expand Up @@ -87,8 +89,7 @@ export async function sendArtworkEmail(artist, date) {
"Your show artwork for " + dayjs(date).format("dddd") + " is now ready",
reply_to: [
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
],
react: ShowArtworkEmail({
Expand Down
10 changes: 5 additions & 5 deletions views/admin/calendarInsta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ export default function CalendarInsta() {
}, 1000);
}, [copied]);

// useEffect(() => {
// onToggle(dialogOpen);
// }, [dialogOpen]);

return (
<Dialog.Root
open={dialogOpen}
Expand All @@ -82,7 +78,7 @@ export default function CalendarInsta() {
contentEditable={true}
suppressContentEditableWarning={true}
>
📻 {dayjs().format("dddd")}
📻 {dayjs().format("dddd")} (all times CET)
<br />
<br />
{data.map((show) => (
Expand All @@ -91,6 +87,10 @@ export default function CalendarInsta() {
<br />
</>
))}
<>
{data[data.length - 1].dateEnd} Repeats Playlist
<br />
</>
<br />
🎧 Listen live:
<br />
Expand Down

0 comments on commit ae5a9e6

Please sign in to comment.