Add setter for non authorized clients

This commit is contained in:
kPherox 2019-04-27 18:21:18 +09:00
parent aeda2b14c6
commit 9f7d54cb88
No known key found for this signature in database
GPG Key ID: C04751C2BFA2F62D

View File

@ -16,21 +16,22 @@ export default class Clients {
let clients = protocol === 'http' ? this.nonAuthorizedHTTP : this.nonAuthorizedWebsocket
if (!clients.has(domain)) {
this.createNoAuthClient(domain)
this.setNoAuthClient(protocol, domain, this.createNoAuthClient(protocol, domain))
}
return clients.get(domain)!
}
private static createNoAuthClient(domain: string) {
public static setNoAuthClient(protocol: Protocol, domain: string, client: Mastodon) {
let clients = protocol === 'http' ? this.nonAuthorizedHTTP : this.nonAuthorizedWebsocket
clients.set(domain, client)
}
this.nonAuthorizedHTTP.set(domain, new Mastodon(
private static createNoAuthClient(protocol: Protocol, domain: string): Mastodon {
let scheme = protocol === 'http' ? 'https://' : 'wss://'
return new Mastodon(
'',
'https://' + domain + '/api/v1'
))
this.nonAuthorizedWebsocket.set(domain, new Mastodon(
'',
'wss://' + domain + '/api/v1'
))
scheme + domain + '/api/v1'
)
}
}