diff --git a/src/Data/Subscriptions/SubscriptionManager.cs b/src/Data/Subscriptions/SubscriptionManager.cs
index 373a5c98..36b4dc93 100644
--- a/src/Data/Subscriptions/SubscriptionManager.cs
+++ b/src/Data/Subscriptions/SubscriptionManager.cs
@@ -11,6 +11,9 @@
using WhMgr.Data.Subscriptions.Models;
using WhMgr.Diagnostics;
+ ///
+ /// User subscription manager class
+ ///
public class SubscriptionManager
{
#region Variables
@@ -29,6 +32,9 @@ public class SubscriptionManager
#region Properties
+ ///
+ /// Gets all current user subscriptions
+ ///
public IReadOnlyList Subscriptions => _subscriptions;
#endregion
@@ -64,22 +70,22 @@ public SubscriptionManager(WhConfig whConfig)
// Reload subscriptions every 60 seconds to account for UI changes
_reloadTimer = new Timer(_whConfig.ReloadSubscriptionChangesMinutes * 60 * 1000);
- _reloadTimer.Elapsed += OnReloadTimerElapsed;
+ _reloadTimer.Elapsed += (sender, e) => ReloadSubscriptions();
_reloadTimer.Start();
ReloadSubscriptions();
}
- private void OnReloadTimerElapsed(object sender, ElapsedEventArgs e)
- {
- // TODO: Only reload based on last_changed timestamp in metadata table
- ReloadSubscriptions();
- }
-
#endregion
#region User
+ ///
+ /// Get user subscription from guild id and user id
+ ///
+ /// Discord guild id to lookup
+ /// Discord user id to lookup
+ /// Returns user subscription object
public SubscriptionObject GetUserSubscriptions(ulong guildId, ulong userId)
{
if (!IsDbConnectionOpen())
@@ -104,6 +110,11 @@ public SubscriptionObject GetUserSubscriptions(ulong guildId, ulong userId)
}
}
+ ///
+ /// Get user subscriptions from subscribed Pokemon id
+ ///
+ /// Pokemon ID to lookup
+ /// Returns list of user subscription objects
public List GetUserSubscriptionsByPokemonId(int pokeId)
{
return _subscriptions?
@@ -114,6 +125,11 @@ public List GetUserSubscriptionsByPokemonId(int pokeId)
.ToList();
}
+ ///
+ /// Get user subscriptions from subscribed PvP Pokemon id
+ ///
+ /// Pokemon ID to lookup
+ /// Returns list of user subscription objects
public List GetUserSubscriptionsByPvPPokemonId(int pokeId)
{
return _subscriptions?
@@ -124,6 +140,11 @@ public List GetUserSubscriptionsByPvPPokemonId(int pokeId)
.ToList();
}
+ ///
+ /// Get user subscriptions from subscribed Raid Pokemon id
+ ///
+ /// Pokemon ID to lookup
+ /// Returns list of user subscription objects
public List GetUserSubscriptionsByRaidBossId(int pokeId)
{
return _subscriptions?
@@ -134,6 +155,11 @@ public List GetUserSubscriptionsByRaidBossId(int pokeId)
.ToList();
}
+ ///
+ /// Get user subscriptions from subscribed Quest reward keyword
+ ///
+ /// Ques reward keyword
+ /// Returns list of user subscription objects
public List GetUserSubscriptionsByQuestReward(string reward)
{
return _subscriptions?
@@ -144,6 +170,11 @@ public List GetUserSubscriptionsByQuestReward(string reward)
.ToList();
}
+ ///
+ /// Gets user subscriptions from subscribed Invasion encounter rewards
+ ///
+ /// Invasion encounter rewards
+ /// Returns list of user subscription objects
public List GetUserSubscriptionsByEncounterReward(List encounterRewards)
{
return _subscriptions?
@@ -154,6 +185,10 @@ public List GetUserSubscriptionsByEncounterReward(List
.ToList();
}
+ ///
+ /// Get all enabled user subscriptions
+ ///
+ /// Returns all enabled user subscription objects
public List GetUserSubscriptions()
{
try
@@ -186,8 +221,13 @@ public List GetUserSubscriptions()
return null;
}
+ ///
+ /// Reload all user subscriptions
+ ///
public void ReloadSubscriptions()
{
+ // TODO: Only reload based on last_changed timestamp in metadata table
+
var subs = GetUserSubscriptions();
if (subs == null)
return;
@@ -199,6 +239,12 @@ public void ReloadSubscriptions()
#region Remove
+ ///
+ /// Remove all user subscriptions based on guild id and user id
+ ///
+ /// Discord guild id to lookup
+ /// Discord user id to lookup
+ /// Returns true if all subscriptions were removed, otherwise false.
public static bool RemoveAllUserSubscriptions(ulong guildId, ulong userId)
{
_logger.Trace($"SubscriptionManager::RemoveAllUserSubscription [GuildId={guildId}, UserId={userId}]");