mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
Populate relay codes.
This commit is contained in:
parent
e2665771de
commit
b89eabcdeb
@ -50,11 +50,17 @@ namespace Remotely.Desktop.Core.Services
|
||||
|
||||
var config = _configService.GetConfig();
|
||||
|
||||
var host = _conductor?.Host;
|
||||
if (string.IsNullOrWhiteSpace(host))
|
||||
{
|
||||
host = config.Host;
|
||||
}
|
||||
|
||||
var fileName = Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().MainModule.FileName);
|
||||
|
||||
if (fileName.Contains("[") &&
|
||||
fileName.Contains("]") &&
|
||||
!string.IsNullOrWhiteSpace(_conductor?.Host))
|
||||
!string.IsNullOrWhiteSpace(host))
|
||||
{
|
||||
var codeLength = AppConstants.RelayCodeLength + 2;
|
||||
|
||||
@ -65,11 +71,11 @@ namespace Remotely.Desktop.Core.Services
|
||||
{
|
||||
var relayCode = codeSection[1..5];
|
||||
|
||||
using var response = await httpClient.GetAsync($"{_conductor.Host}/api/Relay/{relayCode}").ConfigureAwait(false);
|
||||
using var response = await httpClient.GetAsync($"{host.TrimEnd('/')}/api/Relay/{relayCode}").ConfigureAwait(false);
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var organizationId = await response.Content.ReadAsStringAsync();
|
||||
config.Host = _conductor.Host;
|
||||
config.Host = host;
|
||||
config.OrganizationId = organizationId;
|
||||
_configService.Save(config);
|
||||
|
||||
@ -81,12 +87,12 @@ namespace Remotely.Desktop.Core.Services
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(_conductor?.Host))
|
||||
if (!string.IsNullOrWhiteSpace(host))
|
||||
{
|
||||
config.Host = _conductor.Host;
|
||||
config.Host = host;
|
||||
config.OrganizationId = _conductor.OrganizationId;
|
||||
_configService.Save(config);
|
||||
var brandingUrl = $"{_conductor.Host.TrimEnd('/')}/api/branding/{_conductor.OrganizationId}";
|
||||
var brandingUrl = $"{host.TrimEnd('/')}/api/branding/{_conductor.OrganizationId}";
|
||||
_brandingInfo = await httpClient.GetFromJsonAsync<BrandingInfo>(brandingUrl).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,6 +27,8 @@
|
||||
</div>
|
||||
<div class="form-group mw">
|
||||
<label class="mb-1">Relay Code</label>
|
||||
<span id="relayCodeHelp" class="fas fa-question-circle pointer"></span>
|
||||
<br />
|
||||
<input readonly class="form-control" value="@Model.Organization.RelayCode" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -130,6 +130,8 @@ namespace Remotely.Server.Services
|
||||
|
||||
bool JoinViaInvitation(string userName, string inviteID);
|
||||
|
||||
void PopulateRelayCodes();
|
||||
|
||||
void RemoveDevices(string[] deviceIDs);
|
||||
|
||||
Task<bool> RemoveUserFromDeviceGroup(string orgID, string groupID, string userID);
|
||||
@ -1053,6 +1055,22 @@ namespace Remotely.Server.Services
|
||||
return true;
|
||||
}
|
||||
|
||||
public void PopulateRelayCodes()
|
||||
{
|
||||
foreach (var organization in _dbContext.Organizations)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(organization.RelayCode))
|
||||
{
|
||||
do
|
||||
{
|
||||
organization.RelayCode = new string(Guid.NewGuid().ToString().Take(4).ToArray());
|
||||
}
|
||||
while (_dbContext.Organizations.Any(x => x.ID != organization.ID && x.RelayCode == organization.RelayCode));
|
||||
}
|
||||
}
|
||||
_dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
public void RemoveDevices(string[] deviceIDs)
|
||||
{
|
||||
var devices = _dbContext.Devices
|
||||
|
||||
@ -228,12 +228,14 @@ namespace Remotely.Server
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
dataService.WriteEvent(ex, null);
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
|
||||
loggerFactory.AddProvider(new DbLoggerProvider(env, app.ApplicationServices));
|
||||
dataService.SetAllDevicesNotOnline();
|
||||
dataService.CleanupOldRecords();
|
||||
// TODO: Remove after a few versions.
|
||||
dataService.PopulateRelayCodes();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -23,9 +23,14 @@ export const OrganizationManagement = {
|
||||
|
||||
document.getElementById("defaultOrgHelp").addEventListener("click", () => {
|
||||
ShowModal("Default Organization", `This option is only available for server administrators. When
|
||||
selected during registration, it sets this organization as the default for the server. The
|
||||
quick support downloads, which aren't normally associated with an organization, will use
|
||||
this organization's branding.`);
|
||||
selected, it sets this organization as the default for the server. If the organization can't
|
||||
be determined in the quick support apps, they will use the default organization's branding.`);
|
||||
});
|
||||
|
||||
document.getElementById("relayCodeHelp").addEventListener("click", () => {
|
||||
ShowModal("Relay Code", `This relay code will be appended to EXE filenames. If the clients
|
||||
were built from source and have the server URL embedded, they will use this code to look
|
||||
up the branding to use for your organization.`);
|
||||
});
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user