Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a108c07
send only audio to assembly
boazsender May 12, 2025
a41883b
speedup audio isolation
boazsender May 15, 2025
eba856e
Add secrets back.
boazsender May 28, 2025
9807b3f
Merge pull request #1813 from boazsender/automated-transcriptions
Mephistic May 28, 2025
144b18f
Increase hearing scraper timeout to 8 minutes
Mephistic May 29, 2025
52fb08f
Merge pull request #1827 from Mephistic/fix-hearing-scraper
Mephistic May 29, 2025
5a5d99f
Improve ffmpeg logic and file handling.
boazsender May 29, 2025
fc1043a
Merge pull request #1828 from boazsender/automated-transcriptions
Mephistic May 29, 2025
4ce835b
fix(transcriptions): Only process mp4 videos. Before the video archiv…
Mephistic May 29, 2025
94f85a3
Make ffmpeg progress reporting less noisy.
boazsender May 29, 2025
0677b9a
Correct the ffmpeg progress condition so it will be truthy sometimes.
boazsender May 29, 2025
6bf1138
Merge pull request #1829 from Mephistic/allowlist-file-format
Mephistic May 29, 2025
8ccad85
Merge pull request #1830 from boazsender/automated-transcriptions
Mephistic May 29, 2025
dd1f364
Add sentence retreival and storage to transcription webhook.
boazsender May 29, 2025
fd27b67
Use email from user profile instead of firebase auth for now. This is…
Mephistic Jun 2, 2025
a285a21
Update deliverNotifications timezone to the east coast
Mephistic Jun 2, 2025
d9927fe
Merge pull request #1832 from Mephistic/use-profile-email
Mephistic Jun 2, 2025
ceb940a
fix(email): Run copy-handlebars pre-deploy so we can actually access …
Mephistic Jun 3, 2025
732bb90
Merge pull request #1833 from Mephistic/move-email-templates
Mephistic Jun 3, 2025
0137911
Update Firestore rules to allow public reads of transcriptions and ut…
Mephistic Jun 4, 2025
c25c018
Merge pull request #1834 from Mephistic/update-rules
Mephistic Jun 4, 2025
bf1f6ae
fix(notifications): Remove unused httpsDeliverNotifications firebase …
Mephistic Jun 6, 2025
a3082e8
chore(notifications): removing old notification script - this predate…
Mephistic Jun 6, 2025
3d83dce
chore(notifications): Delete httpsCleanNotifications firebase functio…
Mephistic Jun 6, 2025
0f37cf7
Merge pull request #1835 from Mephistic/fix-notif-object
Mephistic Jun 7, 2025
8fe9d69
fix(email): Switch email image links to the mapletestimony.org domain…
Mephistic Jun 9, 2025
fcf55d1
fix(email): Include real domain with CSS styles too - they don't seem…
Mephistic Jun 9, 2025
1928689
Merge pull request #1836 from Mephistic/fix-email-image-urls
Mephistic Jun 9, 2025
6282a57
Move from saving transcribed sentences to paragraphs.
boazsender Jun 12, 2025
35105ff
Gaurd against runaway audio processing.
boazsender Jun 12, 2025
2203160
fix(email): Fixing styles in notification email header + bills sectio…
Mephistic Jun 17, 2025
c0090b8
fix(email): Update email styling based on user feedback - minor adjus…
Mephistic Jun 17, 2025
b5f8a5f
Merge pull request #1839 from Mephistic/fix-email-styles
Mephistic Jun 18, 2025
a31fef3
Merge pull request #1831 from boazsender/automated-transcriptions
Mephistic Jun 18, 2025
35d60a2
fix(email): Update notification email styles - increase font-size and…
Mephistic Jun 18, 2025
c9a2396
Merge pull request #1842 from Mephistic/more-email-styles
Mephistic Jun 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"functions": {
"predeploy": ["yarn build:functions"],
"source": "functions",
"runtime": "nodejs18"
"runtime": "nodejs18",
"runtimeConfig": ".runtimeconfig.json"
},
"firestore": {
"rules": "firestore.rules",
Expand Down
11 changes: 11 additions & 0 deletions firestore.rules
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,16 @@ service cloud.firestore {
allow read, write: if request.auth.token.get("role", "user") == "admin"
}
}
match /transcriptions/{tid} {
// public, read-only
allow read: if true
allow write: if false

// public, read-only
match /utterances/{uid} {
allow read: if true
allow write: if false
}
}
}
}
9 changes: 9 additions & 0 deletions functions/.runtimeconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"runtime": {
"nodejs18": {
"apt": {
"packages": ["ffmpeg"]
}
}
}
}
2 changes: 2 additions & 0 deletions functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"date-fns": "^2.30.0",
"firebase-admin": "^10",
"firebase-functions": "^3.22.0",
"fluent-ffmpeg": "^2.1.3",
"fuse.js": "6.5.3",
"handlebars": "^4.7.8",
"js-sha256": "^0.11.0",
Expand All @@ -34,6 +35,7 @@
"zod": "^3.20.2"
},
"devDependencies": {
"@types/fluent-ffmpeg": "^2.1.27",
"@types/jest": "^27.4.0",
"@types/jsdom": "^21.1.7",
"@types/luxon": "^2.0.9",
Expand Down
1 change: 0 additions & 1 deletion functions/src/email/digestEmail.handlebars
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<html>
<head>
<title>Digest Email</title>
<link rel="stylesheet" type="text/css" href="email/style.css" />
</head>

<body style="background: white; width: 600px; min-height: 80vh; font-family: 'Nunito';
Expand Down
1 change: 1 addition & 0 deletions functions/src/email/handlebarsHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const registerHelpers = () => {
handlebars.registerHelper("minusFour", helpers.minusFour)
handlebars.registerHelper("noUpdatesFormat", helpers.noUpdatesFormat)
handlebars.registerHelper("toLowerCase", helpers.toLowerCase)
handlebars.registerHelper("pluralize", helpers.pluralize)
}

// Register all Handlebars partials
Expand Down
11 changes: 11 additions & 0 deletions functions/src/email/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { BillDigest } from "../notifications/emailTypes"

export function addCounts() {
let sum = 0
for (let i = 0; i < arguments.length - 1; i++) {
Expand Down Expand Up @@ -56,3 +58,12 @@ export function toLowerCase(aString: unknown) {
console.error(`toLowerCase received a non-string value: ${aString}`)
return undefined
}

// TODO: This will be replaced by I18n logic when we implement it for emails
export function pluralize(bill: BillDigest): string {
if (bill.endorseCount + bill.neutralCount + bill.opposeCount === 1) {
return "Testimony"
} else {
return "Testimonies"
}
}
55 changes: 27 additions & 28 deletions functions/src/email/partials/bills/bill.handlebars
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
<article id="bill">
<div style="font-weight: 500; font-size: 22px; line-height: 125%;
text-decoration-line: underline; color: #000000; margin-bottom: 24px">
{{this.billId}}
<div style="font-weight: 500; font-size: 20px; line-height: 125%;
text-decoration-line: underline; color: #000000; margin-bottom: 4px">
<a href="https://mapletestimony.org/bills/{{this.billCourt}}/{{this.billId}}" target="_blank" rel="noopener noreferrer" style="color: inherit">{{this.billId}}</a>
</div>
<div style="font-weight: 600; font-size: 12px; line-height: 125%;
<div style="font-weight: 600; font-size: 16px; line-height: 125%;
color: #000000; letter-spacing: 0.03em; margin-bottom: 24px">
{{this.billName}}
</div>
<div style="padding: 12px 0px 12px 36px; background: #EAE7E7;
border-radius: 12px; margin-bottom: 36px;">
<div>
<div style="height: 49px; font-weight: 500; font-size: 39px; line-height: 125%;
letter-spacing: -0.015em; color: #000000; margin: auto; text-align: center">
{{addCounts this.endorseCount this.neutralCount this.opposeCount}}
<a href="https://mapletestimony.org/bills/{{this.billCourt}}/{{this.billId}}" target="_blank" rel="noopener noreferrer" style="text-decoration: none; color: inherit">
<div style="padding: 12px 0px 12px 12px; background: #EAE7E7;
border-radius: 12px; margin-bottom: 12px; text-align: center">
<div>
<div style="height: 49px; font-weight: 500; font-size: 39px; line-height: 125%;
letter-spacing: -0.015em; color: #000000; margin: auto; text-align: center">
{{addCounts this.endorseCount this.neutralCount this.opposeCount}}
</div>
</div>
<div style="height: 20px; font-weight: 700; font-size: 16px; line-height: 125%;
letter-spacing: 0.015em; color: #3E3E3E; margin: auto; text-align: center">
New {{pluralize this}}
</div>
<div style="height: 19px; font-weight: 700; font-size: 14px; line-height: 100%;
color: #000000; margin: auto; padding: 16px 0px 26px 0px;
text-align: center">
<img src="https://mapletestimony.org/email/images_no-svgs/endorse.png" alt="checkmark" style="padding-right: 18px"/>
{{this.endorseCount}} Endorse
<img src="https://mapletestimony.org/email/images_no-svgs/neutral.png" alt="dash" style="padding: 0 18px"/>
{{this.neutralCount}} Neutral
<img src="https://mapletestimony.org/email/images_no-svgs/oppose.png" alt="x-mark" style="padding: 0 18px"/>
{{this.opposeCount}} Oppose
</div>
</div>
<div style="height: 20px; font-weight: 700; font-size: 16px; line-height: 125%;
letter-spacing: 0.015em; color: #3E3E3E; margin: auto; text-align: center">
New Testimonies
</div>
<div style="height: 19px; font-weight: 700; font-size: 14px; line-height: 100%;
color: #000000; margin: auto; padding: 16px 0px 26px 0px;
text-align: center">
<img src="email\images_no-svgs\endorse.png" alt="checkmark" style="padding-right: 18px"/>
{{!-- replace with link to mapletestimony.org when going live --}}
{{this.endorseCount}} Endorse
<img src="email\images_no-svgs\neutral.png" alt="dash" style="padding: 0 18px"/>
{{!-- replace with link to mapletestimony.org when going live --}}
{{this.neutralCount}} Neutral
<img src="email\images_no-svgs\oppose.png" alt="x-mark" style="padding: 0 18px"/>
{{!-- replace with link to mapletestimony.org when going live --}}
{{this.opposeCount}} Oppose
</div>
</div>
</a>
</article>
4 changes: 2 additions & 2 deletions functions/src/email/partials/bills/bills.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
</div>
<div>
{{#ifGreaterThan numBillsWithNewTestimony 4}}
<div style="padding: 12px 0px 12px 36px; background: #EAE7E7;
<div style="padding: 12px 0px 12px 12px; background: #EAE7E7;
border-radius: 12px; margin-bottom: 36px;">
<div style="font-weight: 700; font-size: 14px; line-height: 125%; letter-spacing: 3%; margin-top: 5px">
<div style="font-weight: 700; font-size: 14px; line-height: 125%; letter-spacing: 3%; margin-top: 5px; text-align: center">
{{#ifGreaterThan numBillsWithNewTestimony 5}}
{{minusFour numBillsWithNewTestimony}} other bills you follow received testimony since your last update
{{else}}
Expand Down
10 changes: 5 additions & 5 deletions functions/src/email/partials/header.handlebars
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<div id="logo" style="background-color: #1a3185; padding: 16px 20px 16px 50px">
<div id="logo" style="background-color: #1a3185; padding: 16px 20px 16px 50px; text-align: center;">
<img src="https://mapletestimony.org/email/images_no-svgs/Logo.png" alt="Maple Logo" />
</div>

<header style="background-color: #FFFFFF; padding: 24px 0px 12px;
gap: 16px">
gap: 16px; text-align: center;">
<div>
<h2 style="font-weight: 700; font-size: 31px; line-height: 125%; margin: auto; width: 70%; color: #1a3185">
Here is your
{{toLowerCase notificationFrequency}}
report
</h2>
<h2 style="font-weight: 700; font-size: 31px; line-height: 125%; margin: auto; width: 80%; color: #1a3185">
of the Bills and Users you follow!
of the bills and users you follow!
</h2>
<p class="subheadline blue center" style="font-weight: 600; font-size: 12px; line-height: 125%;
<p class="subheadline blue center" style="font-weight: 600; font-size: 16px; line-height: 125%;
color: #1a3185; display: block; margin: auto; width: 30%">
{{formatDate startDate}} - {{formatDate endDate}}
</p>
</div>
<img src="https://mapletestimony.org/email/images_no-svgs/Mail Report.png" alt="Report" style="display: block; margin: auto; width: 32%" />
<img src="https://mapletestimony.org/email/images_no-svgs/Mail Report.png" alt="Report" style="display: block; margin: auto; width: 16%" />
</header>
2 changes: 1 addition & 1 deletion functions/src/email/partials/newsFeedLink.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
target="_blank"
rel="noopener noreferrer"
>
<img src="email\images_no-svgs\newspaper.png" alt="" />
<img src="https://mapletestimony.org/email/images_no-svgs/newspaper.png" alt="" />
Newsfeed
</a>
</p>
Expand Down
2 changes: 1 addition & 1 deletion functions/src/email/partials/noUpdates.handlebars
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div style="padding-top: 12px; padding-bottom: 20px; display: block; margin: auto; width: 65%">
<div style="padding-top: 12px; padding-bottom: 20px; display: block; margin: auto; width: 65%; text-align: center;">
<img src="https://mapletestimony.org/email/images_no-svgs/empty-mail.png" alt="Empty Mail" />
</div>
<h5 style="font-weight: 600; font-size: 25px; line-height: 125%; margin-bottom: 0px;
Expand Down
78 changes: 47 additions & 31 deletions functions/src/email/partials/users/user.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,27 @@
<div style="font-weight: 500; font-size: 22px; line-height: 125%; color: #000000;
margin-right: auto"
>
{{this.userName}}
<a href="https://mapletestimony.org/profile?id={{this.userId}}" target="_blank" rel="noopener noreferrer" style="color: inherit">{{this.userName}}</a>
</div>
<div style="margin-right: auto;">
<div style="margin-right: 24px; display: inline-block">
<div style="width: 37px; height: 76px; font-weight: 600; font-size: 61px;
line-height: 125%; letter-spacing: -0.03em; color: #1A3185;
line-height: 125%; letter-spacing: -0.03em; color: #000000;
margin-left: auto; margin-right: auto;"
>
{{this.newTestimonyCount}}
</div>
<div style="font-weight: 700; font-size: 16px; line-height: 125%; letter-spacing: 0.015em;
color: #000000; width: 135px"
>
New Testimonies
{{#ifGreaterThan this.newTestimonyCount 1}}
New Testimonies
{{else}}
New Testimony
{{/ifGreaterThan}}
</div>
</div>
<table style="display: inline-block; margin: 0; padding: 0">
<table style="display: inline-block; margin: 0; padding: 0; font-size: 20px;">
<tr>
{{!-- the possibility of the 6th item being handled differently and
the possibility of more than 6 data points makes iterating
Expand All @@ -29,29 +33,33 @@
{{!-- Item 1 --}}

{{#if this.bills.0.billId}}
<td style="width: 75px">
<td style="width: 100px">
<div style="text-decoration-line: underline; display: inline-block; margin-right: 15px">
{{this.bills.0.billId}}
<a href="https://mapletestimony.org/bills/{{this.bills.0.court}}/{{this.bills.0.billId}}" target="_blank" rel="noopener noreferrer" style="color: inherit">
{{this.bills.0.billId}}
</a>
</div>
</td>
<td style="width: 75px">
<td style="width: 50px">
<img
src="email\images_no-svgs\\{{this.bills.0.position}}.jpg"
src="https://mapletestimony.org/email/images_no-svgs/{{this.bills.0.position}}.jpg"
/>
</td>
{{/if}}

{{!-- Item 2 --}}

{{#if this.bills.1.billId}}
<td style="width: 75px">
<td style="width: 100px">
<div style="text-decoration-line: underline; display: inline-block; margin-right: 15px">
{{this.bills.1.billId}}
<a href="https://mapletestimony.org/bills/{{this.bills.1.court}}/{{this.bills.1.billId}}" target="_blank" rel="noopener noreferrer" style="color: inherit">
{{this.bills.1.billId}}
</a>
</div>
</td>
<td style="width: 75px">
<td style="width: 50px">
<img
src="email\images_no-svgs\\{{this.bills.1.position}}.jpg"
src="https://mapletestimony.org/email/images_no-svgs/{{this.bills.1.position}}.jpg"
/>
</td>
{{/if}}
Expand All @@ -60,29 +68,33 @@
{{!-- Item 3 --}}

{{#if this.bills.2.billId}}
<td style="width: 75px">
<td style="width: 100px">
<div style="text-decoration-line: underline; display: inline-block; margin-right: 15px">
{{this.bills.2.billId}}
<a href="https://mapletestimony.org/bills/{{this.bills.2.court}}/{{this.bills.2.billId}}" target="_blank" rel="noopener noreferrer" style="color: inherit">
{{this.bills.2.billId}}
</a>
</div>
</td>
<td style="width: 75px">
<td style="width: 50px">
<img
src="email\images_no-svgs\\{{this.bills.2.position}}.jpg"
src="https://mapletestimony.org/email/images_no-svgs/{{this.bills.2.position}}.jpg"
/>
</td>
{{/if}}

{{!-- Item 4 --}}

{{#if this.bills.3.billId}}
<td style="width: 75px">
<td style="width: 100px">
<div style="text-decoration-line: underline; display: inline-block; margin-right: 15px">
{{this.bills.3.billId}}
<a href="https://mapletestimony.org/bills/{{this.bills.3.court}}/{{this.bills.3.billId}}" target="_blank" rel="noopener noreferrer" style="color: inherit">
{{this.bills.3.billId}}
</a>
</div>
</td>
<td style="width: 75px">
<td style="width: 50px">
<img
src="email\images_no-svgs\\{{this.bills.3.position}}.jpg"
src="https://mapletestimony.org/email/images_no-svgs/{{this.bills.3.position}}.jpg"
/>
</td>
{{/if}}
Expand All @@ -92,14 +104,16 @@
{{!-- Item 5 --}}

{{#if this.bills.4.billId}}
<td style="width: 75px">
<td style="width: 100px">
<div style="text-decoration-line: underline; display: inline-block; margin-right: 15px">
{{this.bills.4.billId}}
<a href="https://mapletestimony.org/bills/{{this.bills.4.court}}/{{this.bills.4.billId}}" target="_blank" rel="noopener noreferrer" style="color: inherit">
{{this.bills.4.billId}}
</a>
</div>
</td>
<td style="width: 75px">
<td style="width: 50px">
<img
src="email\images_no-svgs\\{{this.bills.4.position}}.jpg"
src="https://mapletestimony.org/email/images_no-svgs/{{this.bills.4.position}}.jpg"
/>
</td>
{{/if}}
Expand All @@ -108,25 +122,27 @@

{{#if this.bills.5.billId}}
{{#if this.bills.6.billId}}
<td style="width: 75px">
<a class="orgItemText" href="https://mapletestimony.org/profile" target="_blank" rel="noopener noreferrer">
<td style="width: 100px">
<a class="orgItemText" href="https://mapletestimony.org/profile?id={{userId}}" target="_blank" rel="noopener noreferrer">
see more
</a>
</td>
<td style="width: 75px">
<td style="width: 50px">
<div style="color: #1A3185; font-weight: bold;">
+
</div>
</td>
{{else}}
<td style="width: 75px">
<td style="width: 100px">
<div style="text-decoration-line: underline; display: inline-block; margin-right: 15px">
{{this.bills.5.billId}}
<a href="https://mapletestimony.org/bills/{{this.bills.5.court}}/{{this.bills.5.billId}}" target="_blank" rel="noopener noreferrer" style="color: inherit">
{{this.bills.5.billId}}
</a>
</div>
</td>
<td style="width: 75px">
<td style="width: 50px">
<img
src="email\images_no-svgs\\{{this.bills.5.position}}.jpg"
src="https://mapletestimony.org/email/images_no-svgs/{{this.bills.5.position}}.jpg"
/>
</td>
{{/if}}
Expand Down
4 changes: 2 additions & 2 deletions functions/src/email/partials/users/users.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
</div>
<div></div>
{{#ifGreaterThan numUsersWithNewTestimony 4}}
<div style="padding: 12px 0px 12px 36px; background: #EAE7E7;
<div style="padding: 12px 0px 12px 12px; background: #EAE7E7;
border-radius: 12px; margin-bottom: 36px;">
<div style="font-weight: 700; font-size: 14px; line-height: 125%; letter-spacing: 3%; margin-top: 5px">
<div style="font-weight: 700; font-size: 14px; line-height: 125%; letter-spacing: 3%; margin-top: 5px; text-align: center">
{{#ifGreaterThan numUsersWithNewTestimony 5}}
{{minusFour numUsersWithNewTestimony}} other users you follow posted testimony since your last update
{{else}}
Expand Down
Loading