diff options
| author | Hazelnoot <acomputerdog@gmail.com> | 2025-04-29 16:07:56 -0400 |
|---|---|---|
| committer | Hazelnoot <acomputerdog@gmail.com> | 2025-04-29 16:07:56 -0400 |
| commit | dc9106dfb3426482b298f05d27e5d6ba72053cb6 (patch) | |
| tree | fed821bfa05ee51ec00ee60ce87d943ee1d188ee /packages/megalodon/src/misskey/api_client.ts | |
| parent | Merge branch 'misskey-develop' into merge/2025-03-24 (diff) | |
| download | sharkey-dc9106dfb3426482b298f05d27e5d6ba72053cb6.tar.gz sharkey-dc9106dfb3426482b298f05d27e5d6ba72053cb6.tar.bz2 sharkey-dc9106dfb3426482b298f05d27e5d6ba72053cb6.zip | |
remove outdated packages from megalodon
Diffstat (limited to 'packages/megalodon/src/misskey/api_client.ts')
| -rw-r--r-- | packages/megalodon/src/misskey/api_client.ts | 43 |
1 files changed, 2 insertions, 41 deletions
diff --git a/packages/megalodon/src/misskey/api_client.ts b/packages/megalodon/src/misskey/api_client.ts index 4d97ae497c..17a59c7c76 100644 --- a/packages/megalodon/src/misskey/api_client.ts +++ b/packages/megalodon/src/misskey/api_client.ts @@ -3,11 +3,9 @@ import dayjs from 'dayjs' import FormData from 'form-data' import { DEFAULT_UA } from '../default' -import proxyAgent, { ProxyConfig } from '../proxy_config' import Response from '../response' import MisskeyEntity from './entity' import MegalodonEntity from '../entity' -import WebSocket from './web_socket' import MisskeyNotificationType from './notification' import * as NotificationType from '../notification' import { UnknownNotificationTypeError } from '../notification'; @@ -555,32 +553,28 @@ namespace MisskeyAPI { get<T = any>(path: string, params?: any, headers?: { [key: string]: string }): Promise<Response<T>> post<T = any>(path: string, params?: any, headers?: { [key: string]: string }): Promise<Response<T>> cancel(): void - socket(channel: 'user' | 'localTimeline' | 'hybridTimeline' | 'globalTimeline' | 'conversation' | 'list', listId?: string): WebSocket } /** * Misskey API client. * - * Usign axios for request, you will handle promises. + * Using axios for request, you will handle promises. */ export class Client implements Interface { private accessToken: string | null private baseUrl: string private userAgent: string private abortController: AbortController - private proxyConfig: ProxyConfig | false = false /** * @param baseUrl hostname or base URL * @param accessToken access token from OAuth2 authorization * @param userAgent UserAgent is specified in header on request. - * @param proxyConfig Proxy setting, or set false if don't use proxy. */ - constructor(baseUrl: string, accessToken: string | null, userAgent: string = DEFAULT_UA, proxyConfig: ProxyConfig | false = false) { + constructor(baseUrl: string, accessToken: string | null, userAgent: string = DEFAULT_UA) { this.accessToken = accessToken this.baseUrl = baseUrl this.userAgent = userAgent - this.proxyConfig = proxyConfig this.abortController = new AbortController() axios.defaults.signal = this.abortController.signal } @@ -595,12 +589,6 @@ namespace MisskeyAPI { maxContentLength: Infinity, maxBodyLength: Infinity } - if (this.proxyConfig) { - options = Object.assign(options, { - httpAgent: proxyAgent(this.proxyConfig), - httpsAgent: proxyAgent(this.proxyConfig) - }) - } return axios.get<T>(this.baseUrl + path, options).then((resp: AxiosResponse<T>) => { const res: Response<T> = { data: resp.data, @@ -624,12 +612,6 @@ namespace MisskeyAPI { maxContentLength: Infinity, maxBodyLength: Infinity } - if (this.proxyConfig) { - options = Object.assign(options, { - httpAgent: proxyAgent(this.proxyConfig), - httpsAgent: proxyAgent(this.proxyConfig) - }) - } let bodyParams = params if (this.accessToken) { if (params instanceof FormData) { @@ -658,27 +640,6 @@ namespace MisskeyAPI { public cancel(): void { return this.abortController.abort() } - - /** - * Get connection and receive websocket connection for Misskey API. - * - * @param channel Channel name is user, localTimeline, hybridTimeline, globalTimeline, conversation or list. - * @param listId This parameter is required only list channel. - */ - public socket( - channel: 'user' | 'localTimeline' | 'hybridTimeline' | 'globalTimeline' | 'conversation' | 'list', - listId?: string - ): WebSocket { - if (!this.accessToken) { - throw new Error('accessToken is required') - } - const url = this.baseUrl + '/streaming' - const streaming = new WebSocket(url, channel, this.accessToken, listId, this.userAgent, this.proxyConfig) - process.nextTick(() => { - streaming.start() - }) - return streaming - } } } |