Notifications and sending songs to friends
Reactions to your songs, new followers, and songs sent to you are now notifications: a bell on the feed (app and website) with an unread count that updates live, and a list that marks them read. "Send ✉" on a song sends it to people who follow you, with an optional note. Settings picks which kinds to be notified about. Push delivery uses no third-party accounts: - Android: UnifiedPush through a distributor app (ntfy), pointed at our own ntfy server (docker-compose.ntfy.yml). Works the same in the F-Droid build; no Firebase. - Browsers: standard Web Push from the existing service worker. Both use Web Push encryption with a VAPID key pair the server makes and keeps in the database. Push addresses are checked like any other user-supplied URL. Setup is in docs/PUSH.md; the privacy page covers the new data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { notificationPath, notificationPrefs, notificationText } from './notifications';
|
||||
|
||||
const actor = { id: 'u1', username: 'bob', displayName: 'Bob', avatarUrl: null };
|
||||
const track = { id: 't1', title: 'Teardrop', artist: 'Massive Attack', album: null, artworkUrl: null, durationMs: null, isrc: null, links: {} };
|
||||
|
||||
describe('notifications', () => {
|
||||
it('words each kind', () => {
|
||||
expect(notificationText({ type: 'reaction', actor, track, emoji: '🔥', message: null })).toEqual({
|
||||
title: 'Bob reacted 🔥',
|
||||
body: 'to Teardrop by Massive Attack',
|
||||
});
|
||||
expect(notificationText({ type: 'follow', actor: { ...actor, displayName: null }, track: null, emoji: null, message: null }).title).toBe(
|
||||
'bob followed you',
|
||||
);
|
||||
expect(notificationText({ type: 'share', actor, track, emoji: null, message: 'so good' }).body).toBe('Teardrop by Massive Attack: “so good”');
|
||||
});
|
||||
|
||||
it('links songs to the song and follows to the person', () => {
|
||||
expect(notificationPath({ type: 'share', actor, track })).toBe('/t/t1');
|
||||
expect(notificationPath({ type: 'follow', actor, track: null })).toBe('/u/bob');
|
||||
});
|
||||
|
||||
it('treats missing settings as on', () => {
|
||||
expect(notificationPrefs({ follow: false })).toEqual({ reaction: true, follow: false, share: true });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user