mirror of
https://github.com/binwiederhier/ntfy.git
synced 2024-06-29 19:40:45 +12:00
31 lines
738 B
JavaScript
31 lines
738 B
JavaScript
import {topicUrl, shortTopicUrl, topicUrlWs} from './utils';
|
|
|
|
export default class Subscription {
|
|
id = '';
|
|
baseUrl = '';
|
|
topic = '';
|
|
notifications = [];
|
|
lastActive = null;
|
|
constructor(baseUrl, topic) {
|
|
this.id = topicUrl(baseUrl, topic);
|
|
this.baseUrl = baseUrl;
|
|
this.topic = topic;
|
|
}
|
|
addNotification(notification) {
|
|
if (notification.time === null) {
|
|
return;
|
|
}
|
|
this.notifications.push(notification);
|
|
this.lastActive = notification.time;
|
|
}
|
|
url() {
|
|
return this.id;
|
|
}
|
|
wsUrl() {
|
|
return topicUrlWs(this.baseUrl, this.topic);
|
|
}
|
|
shortUrl() {
|
|
return shortTopicUrl(this.baseUrl, this.topic);
|
|
}
|
|
}
|