Skip to content
Permalink
Browse files

Merge pull request #3807 from ArchonMegalon/master

http-handler for discord
  • Loading branch information...
ArchonMegalon committed Aug 8, 2019
2 parents 11b1172 + fbc8e11 commit d5d29285eb4b135b8c0097956fb0adc0bb62cd7f

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

@@ -21,6 +21,7 @@
using SINners;
using SINners.Models;
using MessageBox = System.Windows.Forms.MessageBox;
using Utils = Chummer.Utils;

namespace ChummerHub.Client.UI
{
@@ -89,14 +90,14 @@ async Task<CharacterExtended> GetCharacterExtended(CustomActivity parentActivity
FileName = MyCharacterCache.FilePath
};
var foundchar = (from a in PluginHandler.MainForm.OpenCharacters
where a.FileName == MyCharacterCache.FilePath
select a).ToList();
where a.FileName == MyCharacterCache.FilePath
select a).ToList();
if (foundchar?.Any() == true)
c = foundchar?.FirstOrDefault();
else
{
using (frmLoading frmLoadingForm = new frmLoading
{CharacterFile = MyCharacterCache.FilePath})
{ CharacterFile = MyCharacterCache.FilePath })
{
frmLoadingForm.Reset(36);
frmLoadingForm.TopMost = true;
@@ -119,7 +120,7 @@ async Task<CharacterExtended> GetCharacterExtended(CustomActivity parentActivity
}
}



if (MyCharacterCache.MyPluginDataDic.TryGetValue("SINnerId", out Object sinneridobj))
{
@@ -132,7 +133,7 @@ async Task<CharacterExtended> GetCharacterExtended(CustomActivity parentActivity
}



if ((String.IsNullOrEmpty(sinnerid)
|| (!Guid.TryParse(sinnerid, out SINid))))
{
@@ -145,7 +146,7 @@ async Task<CharacterExtended> GetCharacterExtended(CustomActivity parentActivity
myState.CurrentProgress = 30;
ReportProgress(myState.CurrentProgress, myState);
}


HttpOperationResponse<ResultSinnerGetSINById> checkresult = null;
//check if char is already online and updated
@@ -234,7 +235,7 @@ private void ShareChummer_ProgressChanged(int progress, MyUserState e)
{
pgbStatus.Value = e.CurrentProgress;
});

if (e is MyUserState us)
{
tbStatus.DoThreadSafe(() =>
@@ -264,5 +265,18 @@ private void BOk_Click(object sender, EventArgs e)
{
MyFrmSINnerShare.Close();
}

private void BMakeDiscordLink_Click(object sender, EventArgs e)
{
if ((!tbLink.Text?.StartsWith("chummer:") == true) || (tbLink.Text == null))
return;
var client = StaticUtils.GetClient();
string newuri = client.BaseUri + "/Home";
newuri += "/RedirectToChummer?args=";
newuri += Uri.EscapeDataString(tbLink.Text);
tbLink.Text = newuri;
Clipboard.SetText(tbLink.Text);
tbStatus.Text += "Link changed" + Environment.NewLine;
}
}
}
@@ -46,5 +46,14 @@ public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}

[AllowAnonymous]
[HttpGet]
public RedirectResult RedirectToChummer(string args)
{
if (String.IsNullOrEmpty(args))
throw new ArgumentException("url unknown: " + args);
return Redirect(args);
}
}
}

0 comments on commit d5d2928

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