Skip to content

Commit

Permalink
Fix issue with notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
wh0o7 committed Sep 8, 2023
1 parent 03dff80 commit ec7916b
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions StudentsTimetable/Services/ParseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,29 @@ public async Task ParseDay()

if (groupInfoFromTimetable is null || groupInfoFromTimetable.Equals(groupInfo)) continue;

_ = this._botService.SendAdminMessageAsync(
new SendMessageArgs(0, $"Расписание у группы {groupInfo.Number}"));
try
{
_ = this._botService.SendAdminMessageAsync(
new SendMessageArgs(0, $"Расписание у группы {groupInfo.Number}"));

var userList = (await this._mongoService.Database.GetCollection<User>("Users")
.FindAsync(u => u.Group != null && u.Notifications)).ToList().Where(u =>
{
if (u?.Group != null && int.TryParse(Regex.Replace(u.Group, "[^0-9]", ""), out int userGroupNumber))
{
return userGroupNumber == groupInfo.Number;
}
return false;
})
.ToList();

notificationUserList.AddRange((await this._mongoService.Database.GetCollection<User>("Users")
.FindAsync(u =>
u.Group != null && int.Parse(Regex.Replace(u.Group, "[^0-9]", "")) == groupInfo.Number &&
u.Notifications)).ToList());
notificationUserList.AddRange(userList);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}


Expand Down

0 comments on commit ec7916b

Please sign in to comment.