1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-02 08:32:50 -05:00

keep application cache in sync with service bus

This commit is contained in:
Kyle Spearrin
2019-06-13 00:10:37 -04:00
parent 2d63732085
commit 6f0d64119a
16 changed files with 276 additions and 9 deletions

View File

@ -501,5 +501,27 @@ namespace Bit.Core.Utilities
return !invalid;
}
public static string GetApplicationCacheServiceBusSubcriptionName(GlobalSettings globalSettings)
{
var subName = globalSettings.ServiceBus.ApplicationCacheSubscriptionName;
if(string.IsNullOrWhiteSpace(subName))
{
var websiteInstanceId = Environment.GetEnvironmentVariable("WEBSITE_INSTANCE_ID");
if(string.IsNullOrWhiteSpace(websiteInstanceId))
{
throw new Exception("No service bus subscription name available.");
}
else
{
subName = $"{globalSettings.ProjectName.ToLower()}_{websiteInstanceId}";
if(subName.Length > 50)
{
subName = subName.Substring(0, 50);
}
}
}
return subName;
}
}
}