Allow changing the Misuzu base URL.
This commit is contained in:
parent
3f8c2781ee
commit
2de19035ff
5 changed files with 36 additions and 14 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,6 +6,7 @@ mariadb.txt
|
|||
login_key.txt
|
||||
http-motd.txt
|
||||
_webdb.txt
|
||||
msz_url.txt
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace SharpChat.Flashii {
|
|||
};
|
||||
#endif
|
||||
|
||||
using HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, FlashiiUrls.AUTH) {
|
||||
using HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, FlashiiUrls.AuthURL) {
|
||||
Content = new ByteArrayContent(authRequest.GetJSON()),
|
||||
Headers = {
|
||||
{ @"X-SharpChat-Signature", authRequest.Hash },
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace SharpChat.Flashii {
|
|||
if(httpClient == null)
|
||||
throw new ArgumentNullException(nameof(httpClient));
|
||||
|
||||
using HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, FlashiiUrls.BANS) {
|
||||
using HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, FlashiiUrls.BansURL) {
|
||||
Headers = {
|
||||
{ @"X-SharpChat-Signature", STRING.GetSignedHash() },
|
||||
},
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace SharpChat.Flashii {
|
|||
|
||||
byte[] data = JsonSerializer.SerializeToUtf8Bytes(users);
|
||||
|
||||
using HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, FlashiiUrls.BUMP) {
|
||||
using HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, FlashiiUrls.BumpURL) {
|
||||
Content = new ByteArrayContent(data),
|
||||
Headers = {
|
||||
{ @"X-SharpChat-Signature", data.GetSignedHash() },
|
||||
|
|
|
@ -1,14 +1,35 @@
|
|||
namespace SharpChat.Flashii {
|
||||
public static class FlashiiUrls {
|
||||
public const string BASE_URL =
|
||||
#if DEBUG
|
||||
@"https://misuzu.misaka.nl/_sockchat";
|
||||
#else
|
||||
@"https://flashii.net/_sockchat";
|
||||
#endif
|
||||
using System.IO;
|
||||
|
||||
public const string AUTH = BASE_URL + @"/verify";
|
||||
public const string BANS = BASE_URL + @"/bans";
|
||||
public const string BUMP = BASE_URL + @"/bump";
|
||||
namespace SharpChat.Flashii {
|
||||
public static class FlashiiUrls {
|
||||
private const string BASE_URL_FILE = @"msz_url.txt";
|
||||
private const string BASE_URL = @"https://flashii.net";
|
||||
|
||||
private const string AUTH = BASE_URL + @"/_sockchat/verify";
|
||||
private const string BANS = BASE_URL + @"/_sockchat/bans";
|
||||
private const string BUMP = BASE_URL + @"/_sockchat/bump";
|
||||
|
||||
public static string AuthURL { get; }
|
||||
public static string BansURL { get; }
|
||||
public static string BumpURL { get; }
|
||||
|
||||
static FlashiiUrls() {
|
||||
AuthURL = GetURL(AUTH);
|
||||
BansURL = GetURL(BANS);
|
||||
BumpURL = GetURL(BUMP);
|
||||
}
|
||||
|
||||
public static string GetBaseURL() {
|
||||
if(!File.Exists(BASE_URL_FILE))
|
||||
return BASE_URL;
|
||||
string url = File.ReadAllText(BASE_URL_FILE).Trim().Trim('/');
|
||||
if(string.IsNullOrEmpty(url))
|
||||
return BASE_URL;
|
||||
return url;
|
||||
}
|
||||
|
||||
public static string GetURL(string path) {
|
||||
return GetBaseURL() + path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue