public async Task <List <string> > SubscribeHives(List <string> hives) { var results = new List <string>(); if (hives.IsNullOrEmpty()) { return(results); } var handle = GetUserHandle(); var throttleResult = await ThrottleStore.CheckThrottle(ThrottleAction.SubscribeHives, handle, IsAuthenticated); if (throttleResult.ThrottleRequest) { await SendErrorMessage("Rate Limit", throttleResult.Message); return(results); } foreach (var hive in hives) { var hiveName = HiveValidation.GetHiveName(hive, true); if (string.IsNullOrEmpty(hiveName)) { continue; } await Subscribe(handle, hiveName); results.Add(hiveName); } return(results); }
public async Task <bool> LeaveHive(string hive) { var hiveName = HiveValidation.GetHiveName(hive, true); if (string.IsNullOrEmpty(hiveName)) { return(await SendErrorMessage("Validation Error", "Invalid Hive name")); } var handle = GetUserHandle(); var throttleResult = await ThrottleStore.CheckThrottle(ThrottleAction.LeaveHive, handle, IsAuthenticated); if (throttleResult.ThrottleRequest) { return(await SendErrorMessage("Rate Limit", throttleResult.Message)); } await Unsubscribe(handle, hiveName); return(true); }