🐛 Fix repeated update announcement messages (#23)

This commit is contained in:
Manuel 2022-12-25 22:54:31 +01:00 committed by GitHub
parent 3d722dbc9c
commit f29c22349f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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,