Add client creater for authorized account

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

View File

@ -12,6 +12,14 @@ export default class Clients {
private static nonAuthorizedHTTP: Map<string, Mastodon> = new Map() private static nonAuthorizedHTTP: Map<string, Mastodon> = new Map()
private static nonAuthorizedWebsocket: Map<string, Mastodon> = new Map() private static nonAuthorizedWebsocket: Map<string, Mastodon> = new Map()
public static createAuthClient(protocol: Protocol, domain: string, accessToken: string): Mastodon {
let scheme = protocol === 'http' ? 'https://' : 'wss://'
return new Mastodon(
accessToken,
scheme + domain + '/api/v1'
)
}
public static getNoAuthClient(domain: string, protocol: Protocol = 'http'): Mastodon { public static getNoAuthClient(domain: string, protocol: Protocol = 'http'): Mastodon {
let clients = protocol === 'http' ? this.nonAuthorizedHTTP : this.nonAuthorizedWebsocket let clients = protocol === 'http' ? this.nonAuthorizedHTTP : this.nonAuthorizedWebsocket