Skip to content
Permalink
Browse files

Merge pull request #3806 from ArchonMegalon/master

Fixes to allow anonymous upload of chummers to sinners
  • Loading branch information...
ArchonMegalon committed Aug 7, 2019
2 parents a0f15d0 + 9442eee commit 11b117254a99cb9e6b355ba29a45235bf0904cba
@@ -267,6 +267,13 @@ public static async void MyOnSaveUpload(object sender, Character input)
{
try
{
if (ChummerHub.Client.Properties.Settings.Default.UserModeRegistered == false)
{
string msg = "Public Mode currently does not save to the SINners Plugin by default, even if \"onlinemode\" is enabled!" + Environment.NewLine;
msg += "If you want to use SINners as online store, please register!";
Log.Warn(msg);
return;
}
input.OnSaveCompleted = null;
using (new CursorWait(true, MainForm))
{
@@ -493,7 +500,7 @@ private async void mnuSINnersArchetypes_Click(object sender, EventArgs e)
}
else
{
Program.MainForm.ShowMessageBox("No archetypes found!");
MessageBox.Show("No archetypes found!");
}
}
});
@@ -787,45 +794,46 @@ public static async void HandleNamedPipe_OpenRequest(string argument)
PluginHandler.MainForm.Activate();
});
}
while (PluginHandler.MainForm.Visible == false)
{
Thread.Sleep(TimeSpan.FromSeconds(1));
}
if (argument.StartsWith("Load:"))
var client = StaticUtils.GetClient();
while (PluginHandler.MainForm.Visible == false)
{
Thread.Sleep(TimeSpan.FromSeconds(1));
}
if (argument.StartsWith("Load:"))
{
try
{
try
string SINnerIdvalue = argument.Substring(5);
SINnerIdvalue = SINnerIdvalue.Trim('/');
if (Guid.TryParse(SINnerIdvalue, out Guid SINnerId))
{
string SINnerIdvalue = argument.Substring(5);
SINnerIdvalue = SINnerIdvalue.Trim('/');
if (Guid.TryParse(SINnerIdvalue, out Guid SINnerId))

var found = await client.GetSINByIdWithHttpMessagesAsync(SINnerId);
await ChummerHub.Client.Backend.Utils.HandleError(found, found?.Body);
if (found?.Response.StatusCode == System.Net.HttpStatusCode.OK)
{
var client = StaticUtils.GetClient();
var found = await client.GetSINByIdWithHttpMessagesAsync(SINnerId);
await ChummerHub.Client.Backend.Utils.HandleError(found, found?.Body);
if (found?.Response.StatusCode == System.Net.HttpStatusCode.OK)
{
fileNameToLoad = await ChummerHub.Client.Backend.Utils.DownloadFileTask(found.Body.MySINner, null);
await MainFormLoadChar(fileNameToLoad);
}
else if (found?.Response.StatusCode == HttpStatusCode.NotFound)
{
Program.MainForm.ShowMessageBox("Could not find a SINner with Id " + SINnerId + " online!");
}

fileNameToLoad = await ChummerHub.Client.Backend.Utils.DownloadFileTask(found.Body.MySINner, null);
await MainFormLoadChar(fileNameToLoad);
}
else if (found?.Response.StatusCode == HttpStatusCode.NotFound)
{
PluginHandler.MainForm.ShowMessageBox("Could not find a SINner with Id " + SINnerId + " online!");
}

}
catch (Exception e)
{
Log.Error(e);
Program.MainForm.ShowMessageBox("Error loading SINner: " + e.Message);
}

}
else
catch (Exception e)
{
throw new ArgumentException("Unkown command received: " + argument, nameof(argument));
Log.Error(e);
PluginHandler.MainForm.ShowMessageBox("Error loading SINner: " + e.Message);
}

}
else
{
throw new ArgumentException("Unkown command received: " + argument, nameof(argument));
}
}
}

private static async Task<Character> MainFormLoadChar(string fileToLoad)

Some generated files are not rendered by default. Learn more.

@@ -46,6 +46,7 @@ private void TbSINnerResponseErrorText_VisibleChanged(object sender, EventArgs e
{
this.tbSINnerResponseErrorText.Text = Result.ErrorText;
this.tbSINnerResponseMyExpection.Text = Result.MyException?.ToString();
this.tbInstallationId.Text = Chummer.Properties.Settings.Default.UploadClientId.ToString();
}
}
}

0 comments on commit 11b1172

Please sign in to comment.
You can’t perform that action at this time.