|
|
@@ -32,7 +32,7 @@ var app = builder.Build();
|
|
|
|
var logger = app.Logger;
|
|
|
|
var logger = app.Logger;
|
|
|
|
|
|
|
|
|
|
|
|
logger.LogTrace("Setting up user check timer");
|
|
|
|
logger.LogTrace("Setting up user check timer");
|
|
|
|
var userCheckTimer = new CronTimer("*/1 * * * *", "Europe/Vienna", includingSeconds: false);
|
|
|
|
var userCheckTimer = new CronTimer(AppConfiguration.Instance.UserCheckTimerSchedule, "Europe/Vienna", includingSeconds: false);
|
|
|
|
userCheckTimer.OnOccurence += async (s, ea) =>
|
|
|
|
userCheckTimer.OnOccurence += async (s, ea) =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var signalIntegration = app.Services.GetService<SignalIntegration>();
|
|
|
|
var signalIntegration = app.Services.GetService<SignalIntegration>();
|
|
|
@@ -72,7 +72,7 @@ userCheckTimer.OnOccurence += async (s, ea) =>
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
logger.LogTrace("Setting up liked songs playlist creation timer");
|
|
|
|
logger.LogTrace("Setting up liked songs playlist creation timer");
|
|
|
|
var likePlaylistCheckTimer = new CronTimer("*/30 * * * *", "Europe/Vienna", includingSeconds: false);
|
|
|
|
var likePlaylistCheckTimer = new CronTimer(AppConfiguration.Instance.LikePlaylistCheckTimerSchedule, "Europe/Vienna", includingSeconds: false);
|
|
|
|
likePlaylistCheckTimer.OnOccurence += async (s, ea) =>
|
|
|
|
likePlaylistCheckTimer.OnOccurence += async (s, ea) =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var spotifyApiClient = app.Services.GetService<SpotifyApiClient>();
|
|
|
|
var spotifyApiClient = app.Services.GetService<SpotifyApiClient>();
|
|
|
@@ -86,18 +86,21 @@ likePlaylistCheckTimer.OnOccurence += async (s, ea) =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!await spotifyApiClient.IsUserAuthenticatedAsync(user))
|
|
|
|
if (!await spotifyApiClient.IsUserAuthenticatedAsync(user))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
logger.LogWarning($"User {user.LdapUserName} is not authorized with Spotify - skipping playlist sync");
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var foundPlaylist = dci.SmartPlaylistDefinitions?.Where(p => p.CreatedBy == user).ToList().Where(p => p.IsThisUsersLikedSongsPlaylist).SingleOrDefault();
|
|
|
|
var foundPlaylist = dci.SmartPlaylistDefinitions?.Where(p => p.CreatedBy == user).ToList().Where(p => p.IsThisUsersLikedSongsPlaylist).SingleOrDefault();
|
|
|
|
if (foundPlaylist == null)
|
|
|
|
if (foundPlaylist == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var title = $"{user.PreferredName}'s liked Songs";
|
|
|
|
logger.LogWarning($"Creating liked songs playlist for user {user.LdapUserName}");
|
|
|
|
|
|
|
|
var title = $"{user.PreferredName}'s liked songs";
|
|
|
|
var description = $"A collection of the songs liked by {user.PreferredName} on their 'Song of the day' server instance.";
|
|
|
|
var description = $"A collection of the songs liked by {user.PreferredName} on their 'Song of the day' server instance.";
|
|
|
|
// playlist does not exist yet, creating it
|
|
|
|
// playlist does not exist yet, creating it
|
|
|
|
var newPlaylist = await (await spotifyApiClient.WithUserAuthorizationAsync(user)).CreateSpotifyPlaylist(title, description, false, true, user);
|
|
|
|
var newPlaylist = await (await spotifyApiClient.WithUserAuthorizationAsync(user)).CreateSpotifyPlaylist(title, description, false, true, user);
|
|
|
|
await playlistSynchronizer.SynchronizePlaylistAsync(newPlaylist);
|
|
|
|
await playlistSynchronizer.SynchronizePlaylistAsync(newPlaylist);
|
|
|
|
needsSaving = true;
|
|
|
|
needsSaving = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
logger.LogWarning($"Syncing playlists for user {user.LdapUserName}");
|
|
|
|
await playlistSynchronizer.SynchronizeUserPlaylistsAsync(user);
|
|
|
|
await playlistSynchronizer.SynchronizeUserPlaylistsAsync(user);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -109,7 +112,7 @@ likePlaylistCheckTimer.OnOccurence += async (s, ea) =>
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
logger.LogTrace("Setting up user intro timer");
|
|
|
|
logger.LogTrace("Setting up user intro timer");
|
|
|
|
var userIntroTimer = new CronTimer("*/1 * * * *", "Europe/Vienna", includingSeconds: false);
|
|
|
|
var userIntroTimer = new CronTimer(AppConfiguration.Instance.UserIntroCheckTimerSchedule, "Europe/Vienna", includingSeconds: false);
|
|
|
|
userIntroTimer.OnOccurence += async (s, ea) =>
|
|
|
|
userIntroTimer.OnOccurence += async (s, ea) =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var dci = DataContext.Instance;
|
|
|
|
var dci = DataContext.Instance;
|
|
|
@@ -138,7 +141,7 @@ userIntroTimer.OnOccurence += async (s, ea) =>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger.LogTrace("Setting up pick of the day timer");
|
|
|
|
logger.LogTrace("Setting up pick of the day timer");
|
|
|
|
var pickOfTheDayTimer = new CronTimer("0 8 * * *", "Europe/Vienna", includingSeconds: false);
|
|
|
|
var pickOfTheDayTimer = new CronTimer(AppConfiguration.Instance.PickOfTheDayCheckTimerSchedule, "Europe/Vienna", includingSeconds: false);
|
|
|
|
pickOfTheDayTimer.OnOccurence += async (s, ea) =>
|
|
|
|
pickOfTheDayTimer.OnOccurence += async (s, ea) =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var dci = DataContext.Instance;
|
|
|
|
var dci = DataContext.Instance;
|
|
|
@@ -209,10 +212,10 @@ var startUserAssociationProcess = async (User userToAssociate) =>
|
|
|
|
await signalIntegration.SendMessageToUserAsync($"Once you have done so, go to https://sotd.disi.dev, login, navigate to \"Unclaimed Phone Numbers\" and click on the \"Claim\" button to start the claim process.", signalId);
|
|
|
|
await signalIntegration.SendMessageToUserAsync($"Once you have done so, go to https://sotd.disi.dev, login, navigate to \"Unclaimed Phone Numbers\" and click on the \"Claim\" button to start the claim process.", signalId);
|
|
|
|
await signalIntegration.SendMessageToUserAsync($"With a future update you will be required to submit songs via your user account - at that point you will be skipped during the selection process if you have not yet claimed your phone number!", signalId);
|
|
|
|
await signalIntegration.SendMessageToUserAsync($"With a future update you will be required to submit songs via your user account - at that point you will be skipped during the selection process if you have not yet claimed your phone number!", signalId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
logger.LogTrace("Setting up LdapAssociation timer");
|
|
|
|
logger.LogTrace("Setting up LdapAssociation timer");
|
|
|
|
var ldapAssociationTimer = new CronTimer("*/10 * * * *", "Europe/Vienna", includingSeconds: false);
|
|
|
|
var ldapAssociationTimer = new CronTimer(AppConfiguration.Instance.LdapAssociationTimerSchedule, "Europe/Vienna", includingSeconds: false);
|
|
|
|
ldapAssociationTimer.OnOccurence += async (s, ea) =>
|
|
|
|
ldapAssociationTimer.OnOccurence += async (s, ea) =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var dci = DataContext.Instance;
|
|
|
|
var dci = DataContext.Instance;
|
|
|
@@ -241,7 +244,7 @@ ldapAssociationTimer.OnOccurence += async (s, ea) =>
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
logger.LogTrace("Setting up MessageSync timer");
|
|
|
|
logger.LogTrace("Setting up MessageSync timer");
|
|
|
|
var messageSyncTimer = new CronTimer("*/10 * * * *", "Europe/Vienna", includingSeconds: false);
|
|
|
|
var messageSyncTimer = new CronTimer(AppConfiguration.Instance.MessageSyncTimerSchedule, "Europe/Vienna", includingSeconds: false);
|
|
|
|
messageSyncTimer.OnOccurence += async (s, ea) =>
|
|
|
|
messageSyncTimer.OnOccurence += async (s, ea) =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var signalIntegration = app.Services.GetService<SignalIntegration>();
|
|
|
|
var signalIntegration = app.Services.GetService<SignalIntegration>();
|
|
|
|