Skip to content

Commit

Permalink
v0.1.1
Browse files Browse the repository at this point in the history
- Add a highlight effect to the notification when user enters the page from notification popup.
- Support for pushing notification with custom icon.
- Support private access email whitelist.

chore: bump version
  • Loading branch information
backrunner committed Aug 25, 2024
1 parent 2714f3a commit 19e8a5b
Show file tree
Hide file tree
Showing 14 changed files with 366 additions and 53 deletions.
20 changes: 17 additions & 3 deletions Roadmap.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
# Roadmap

- [ ] Add email authentication method
## Planned Features

### v0.2.0

- [ ] Allow to delete a notification in both desktop and mobile devices.
- [ ] Allow to push a notification with approval process.

### Future

- [ ] Add email authentication method
- [ ] Allow to filter notifications by category.
- [ ] Allow to add a ddl to the notification.
- [ ] Allow to add a ttl to the notification.
- [ ] Allow to push an encrypted notification.
- [ ] Add a highlight effect to the notification when user enters the page from notification popup.

## Done

### v0.1.1

- [x] Add a highlight effect to the notification when user enters the page from notification popup.
- [x] Support for pushing notification with custom icon.
- [x] Support private access email whitelist.
1 change: 1 addition & 0 deletions migrations/0001_familiar_vampiro.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `push_notifications` ADD `icon_url` text;
206 changes: 206 additions & 0 deletions migrations/meta/0001_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
{
"version": "6",
"dialect": "sqlite",
"id": "ec4c8523-dbfe-46bb-a3c7-1d50203c40ee",
"prevId": "40aa2ed9-92e2-4e93-84bd-b593eeb10200",
"tables": {
"push_notifications": {
"name": "push_notifications",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"content": {
"name": "content",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"title": {
"name": "title",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"category": {
"name": "category",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"group": {
"name": "group",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"user_email": {
"name": "user_email",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"icon_url": {
"name": "icon_url",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"subscriptions": {
"name": "subscriptions",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"user_email": {
"name": "user_email",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"device_fingerprint": {
"name": "device_fingerprint",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"subscription": {
"name": "subscription",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"user_credentials": {
"name": "user_credentials",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"public_key": {
"name": "public_key",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"private_key": {
"name": "private_key",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"push_token": {
"name": "push_token",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {
"user_credentials_email_unique": {
"name": "user_credentials_email_unique",
"columns": [
"email"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}
7 changes: 7 additions & 0 deletions migrations/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
"when": 1723925170311,
"tag": "0000_brainy_spectrum",
"breakpoints": true
},
{
"idx": 1,
"version": "6",
"when": 1724580633045,
"tag": "0001_familiar_vampiro",
"breakpoints": true
}
]
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "alphapush",
"type": "module",
"version": "0.1.0",
"version": "0.1.1",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
Expand Down
24 changes: 12 additions & 12 deletions public/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ self.addEventListener('push', function (event) {
const data = event.data.json();
const options = {
body: data.body,
icon: '/icon.png',
vibrate: [100, 50, 100],
icon: data.iconUrl || '/icon.png',
vibrate: [50, 10, 60, 25, 90],
data: {
dateOfArrival: Date.now(),
primaryKey: '2',
id: data.id,
category: encodeURIComponent(data.category),
group: encodeURIComponent(data.group),
},
actions: [
{ action: 'explore', title: 'View Details' },
{ action: 'close', title: 'Close' },
],
actions: [{ action: 'detail', title: 'View Details' }],
};

// Immediately show the notification, without using event.waitUntil
Expand All @@ -21,11 +19,13 @@ self.addEventListener('push', function (event) {
self.addEventListener('notificationclick', function (event) {
event.notification.close();

if (event.action === 'explore') {
const notificationData = event.notification.data;

if (event.action === 'detail') {
// Handle the "View Details" action
clients.openWindow('/details');
} else if (event.action === 'close') {
// Handle the "Close" action
clients.openWindow(
`/?notificationId=${notificationData.id}&category=${notificationData.category}&group=${notificationData.group}`,
);
} else {
// Handle the case where the notification itself is clicked
clients.openWindow('/');
Expand Down
5 changes: 4 additions & 1 deletion src/components/common/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ if (session?.user?.email) {
const userCreds = await db.select().from(userCredentials).where(eq(userCredentials.email, session.user.email)).get();
pushToken = userCreds?.pushToken || null;
}
const allowedEmails = import.meta.env.ALLOWED_EMAILS?.split(',').map((email: string) => email.trim()) || [];
const isAllowedUser = session?.user?.email && allowedEmails.includes(session.user.email);
---

<header class="bg-background border rounded-lg shadow-sm mt-4 mb-4">
<div class="container mx-auto px-6 py-3 flex items-center justify-between">
<div class="text font-semibold text-primary">AlphaPush</div>
{
session ? (
isAllowedUser ? (
<TopUser
client:load
userInfo={{
Expand Down
Loading

0 comments on commit 19e8a5b

Please sign in to comment.