mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-25 02:51:57 +01:00
🐛 Fix repeated update announcement messages (#23)
This commit is contained in:
parent
3d722dbc9c
commit
f29c22349f
@ -12,6 +12,7 @@ import { Constants } from '../utils/constants';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class UpdatesService {
|
export class UpdatesService {
|
||||||
private readonly logger = new Logger(UpdatesService.name);
|
private readonly logger = new Logger(UpdatesService.name);
|
||||||
|
private hasAlreadyNotified: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@InjectDiscordClient() private readonly client: Client,
|
@InjectDiscordClient() private readonly client: Client,
|
||||||
@ -22,7 +23,7 @@ export class UpdatesService {
|
|||||||
async handleCron() {
|
async handleCron() {
|
||||||
const isDisabled = process.env.UPDATER_DISABLE_NOTIFICATIONS;
|
const isDisabled = process.env.UPDATER_DISABLE_NOTIFICATIONS;
|
||||||
|
|
||||||
if (isDisabled === 'true') {
|
if (isDisabled === 'true' || this.hasAlreadyNotified) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,6 +37,8 @@ export class UpdatesService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await this.contactOwnerAboutUpdate(currentVersion, latestGitHubRelease);
|
await this.contactOwnerAboutUpdate(currentVersion, latestGitHubRelease);
|
||||||
|
|
||||||
|
this.hasAlreadyNotified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async contactOwnerAboutUpdate(
|
private async contactOwnerAboutUpdate(
|
||||||
@ -93,6 +96,12 @@ export class UpdatesService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async fetchLatestGithubRelease(): Promise<null | GithubRelease> {
|
private async fetchLatestGithubRelease(): Promise<null | GithubRelease> {
|
||||||
|
return {
|
||||||
|
tag_name: '0.0.2',
|
||||||
|
name: 'fefeifheuf',
|
||||||
|
html_url: 'https://github.com',
|
||||||
|
published_at: '2022-12-19T08:52:30Z',
|
||||||
|
};
|
||||||
return axios({
|
return axios({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: Constants.Links.Api.GetLatestRelease,
|
url: Constants.Links.Api.GetLatestRelease,
|
||||||
|
Loading…
Reference in New Issue
Block a user