Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 1x 1x 1x 1x | import { Moment } from 'moment';
import { TwitarrHTTPOptions } from '../api/TwitarrHTTPOptions';
import { AlertResponse } from '../model/AlertResponse';
import { AbstractDAO } from './AbstractDAO';
interface IAlertCounts {
unnoticed_announcements: number;
unnoticed_alerts: boolean;
seamail_unread_count: number;
unnoticed_mentions: number;
unnoticed_upcoming_events: number;
}
export class AlertDAO extends AbstractDAO {
/**
* Retrieve an alert response containing all posts/etc. that are un-viewed.
*/
public async get(last_checked_time?: Moment, no_reset?: boolean) {
const options = new TwitarrHTTPOptions().withParameter('app', 'plain');
if (last_checked_time) {
options.parameters.last_checked_time = '' + last_checked_time.valueOf();
}
if (no_reset) {
options.parameters.no_reset = '' + no_reset;
}
return this.http
.get('/api/v2/alerts', options)
.then(result => this.handleErrors(result))
.then(data => {
return AlertResponse.fromRest(data);
});
}
public async count(last_checked_time?: Moment) {
const options = new TwitarrHTTPOptions().withParameter('app', 'plain');
if (last_checked_time) {
options.parameters.last_checked_time = '' + last_checked_time.valueOf();
}
return this.http
.get('/api/v2/alerts/check', options)
.then(result => this.handleErrors(result))
.then(data => {
return data.alerts as IAlertCounts;
});
}
}
|