mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-04 15:34:13 +00:00 
			
		
		
		
	Use camelCase
This commit is contained in:
		
							parent
							
								
									b8e0ec9edc
								
							
						
					
					
						commit
						9b79a411e0
					
				
					 16 changed files with 34 additions and 42 deletions
				
			
		| 
						 | 
					@ -32,16 +32,12 @@ export default function load() {
 | 
				
			||||||
	mixin.host = url.host;
 | 
						mixin.host = url.host;
 | 
				
			||||||
	mixin.hostname = url.hostname;
 | 
						mixin.hostname = url.hostname;
 | 
				
			||||||
	mixin.scheme = url.protocol.replace(/:$/, '');
 | 
						mixin.scheme = url.protocol.replace(/:$/, '');
 | 
				
			||||||
	mixin.ws_scheme = mixin.scheme.replace('http', 'ws');
 | 
						mixin.wsScheme = mixin.scheme.replace('http', 'ws');
 | 
				
			||||||
	mixin.ws_url = `${mixin.ws_scheme}://${mixin.host}`;
 | 
						mixin.wsUrl = `${mixin.wsScheme}://${mixin.host}`;
 | 
				
			||||||
	mixin.api_url = `${mixin.scheme}://${mixin.host}/api`;
 | 
						mixin.apiUrl = `${mixin.scheme}://${mixin.host}/api`;
 | 
				
			||||||
	mixin.auth_url = `${mixin.scheme}://${mixin.host}/auth`;
 | 
						mixin.authUrl = `${mixin.scheme}://${mixin.host}/auth`;
 | 
				
			||||||
	mixin.dev_url = `${mixin.scheme}://${mixin.host}/dev`;
 | 
						mixin.driveUrl = `${mixin.scheme}://${mixin.host}/files`;
 | 
				
			||||||
	mixin.docs_url = `${mixin.scheme}://${mixin.host}/docs`;
 | 
						mixin.userAgent = `Misskey/${pkg.version} (${config.url})`;
 | 
				
			||||||
	mixin.stats_url = `${mixin.scheme}://${mixin.host}/stats`;
 | 
					 | 
				
			||||||
	mixin.status_url = `${mixin.scheme}://${mixin.host}/status`;
 | 
					 | 
				
			||||||
	mixin.drive_url = `${mixin.scheme}://${mixin.host}/files`;
 | 
					 | 
				
			||||||
	mixin.user_agent = `Misskey/${pkg.version} (${config.url})`;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (config.autoAdmin == null) config.autoAdmin = false;
 | 
						if (config.autoAdmin == null) config.autoAdmin = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,16 +49,12 @@ export type Mixin = {
 | 
				
			||||||
	host: string;
 | 
						host: string;
 | 
				
			||||||
	hostname: string;
 | 
						hostname: string;
 | 
				
			||||||
	scheme: string;
 | 
						scheme: string;
 | 
				
			||||||
	ws_scheme: string;
 | 
						wsScheme: string;
 | 
				
			||||||
	api_url: string;
 | 
						apiUrl: string;
 | 
				
			||||||
	ws_url: string;
 | 
						wsUrl: string;
 | 
				
			||||||
	auth_url: string;
 | 
						authUrl: string;
 | 
				
			||||||
	docs_url: string;
 | 
						driveUrl: string;
 | 
				
			||||||
	stats_url: string;
 | 
						userAgent: string;
 | 
				
			||||||
	status_url: string;
 | 
					 | 
				
			||||||
	dev_url: string;
 | 
					 | 
				
			||||||
	drive_url: string;
 | 
					 | 
				
			||||||
	user_agent: string;
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export type Config = Source & Mixin;
 | 
					export type Config = Source & Mixin;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,9 +14,9 @@ export default function(file: IDriveFile, thumbnail = false): string {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		if (thumbnail) {
 | 
							if (thumbnail) {
 | 
				
			||||||
			return `${config.drive_url}/${file._id}?thumbnail`;
 | 
								return `${config.driveUrl}/${file._id}?thumbnail`;
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			return `${config.drive_url}/${file._id}?web`;
 | 
								return `${config.driveUrl}/${file._id}?web`;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -27,5 +27,5 @@ export function getOriginalUrl(file: IDriveFile) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const accessKey = file.metadata ? file.metadata.accessKey : null;
 | 
						const accessKey = file.metadata ? file.metadata.accessKey : null;
 | 
				
			||||||
	return `${config.drive_url}/${file._id}${accessKey ? '?original=' + accessKey : ''}`;
 | 
						return `${config.driveUrl}/${file._id}${accessKey ? '?original=' + accessKey : ''}`;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -76,8 +76,8 @@ export const pack = (
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_app.iconUrl = _app.icon != null
 | 
						_app.iconUrl = _app.icon != null
 | 
				
			||||||
		? `${config.drive_url}/${_app.icon}`
 | 
							? `${config.driveUrl}/${_app.icon}`
 | 
				
			||||||
		: `${config.drive_url}/app-default.jpg`;
 | 
							: `${config.driveUrl}/app-default.jpg`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (me) {
 | 
						if (me) {
 | 
				
			||||||
		// 既に連携しているか
 | 
							// 既に連携しているか
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -350,7 +350,7 @@ export const pack = (
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (_user.avatarUrl == null) {
 | 
						if (_user.avatarUrl == null) {
 | 
				
			||||||
		_user.avatarUrl = `${config.drive_url}/default-avatar.jpg`;
 | 
							_user.avatarUrl = `${config.driveUrl}/default-avatar.jpg`;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!meId || !meId.equals(_user.id) || !opts.detail) {
 | 
						if (!meId || !meId.equals(_user.id) || !opts.detail) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,7 +45,7 @@ export default (user: ILocalUser, url: string, object: any) => new Promise(async
 | 
				
			||||||
		timeout,
 | 
							timeout,
 | 
				
			||||||
		headers: {
 | 
							headers: {
 | 
				
			||||||
			'Host': host,
 | 
								'Host': host,
 | 
				
			||||||
			'User-Agent': config.user_agent,
 | 
								'User-Agent': config.userAgent,
 | 
				
			||||||
			'Content-Type': 'application/activity+json',
 | 
								'Content-Type': 'application/activity+json',
 | 
				
			||||||
			'Digest': `SHA-256=${hash}`
 | 
								'Digest': `SHA-256=${hash}`
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -60,7 +60,7 @@ export default class Resolver {
 | 
				
			||||||
			proxy: config.proxy,
 | 
								proxy: config.proxy,
 | 
				
			||||||
			timeout: this.timeout,
 | 
								timeout: this.timeout,
 | 
				
			||||||
			headers: {
 | 
								headers: {
 | 
				
			||||||
				'User-Agent': config.user_agent,
 | 
									'User-Agent': config.userAgent,
 | 
				
			||||||
				Accept: 'application/activity+json, application/ld+json'
 | 
									Accept: 'application/activity+json, application/ld+json'
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			json: true
 | 
								json: true
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -52,6 +52,6 @@ export default define(meta, async (ps) => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return {
 | 
						return {
 | 
				
			||||||
		token: doc.token,
 | 
							token: doc.token,
 | 
				
			||||||
		url: `${config.auth_url}/${doc.token}`
 | 
							url: `${config.authUrl}/${doc.token}`
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -73,12 +73,12 @@ export default define(meta, async (ps, user) => {
 | 
				
			||||||
			'metadata.deletedAt': { $exists: false }
 | 
								'metadata.deletedAt': { $exists: false }
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
	} else if (ps.url) {
 | 
						} else if (ps.url) {
 | 
				
			||||||
		const isInternalStorageUrl = ps.url.startsWith(config.drive_url);
 | 
							const isInternalStorageUrl = ps.url.startsWith(config.driveUrl);
 | 
				
			||||||
		if (isInternalStorageUrl) {
 | 
							if (isInternalStorageUrl) {
 | 
				
			||||||
			// Extract file ID from url
 | 
								// Extract file ID from url
 | 
				
			||||||
			// e.g.
 | 
								// e.g.
 | 
				
			||||||
			// http://misskey.local/files/foo?original=bar --> foo
 | 
								// http://misskey.local/files/foo?original=bar --> foo
 | 
				
			||||||
			const fileId = new mongo.ObjectID(ps.url.replace(config.drive_url, '').replace(/\?(.*)$/, '').replace(/\//g, ''));
 | 
								const fileId = new mongo.ObjectID(ps.url.replace(config.driveUrl, '').replace(/\?(.*)$/, '').replace(/\//g, ''));
 | 
				
			||||||
			file = await DriveFile.findOne({
 | 
								file = await DriveFile.findOne({
 | 
				
			||||||
				_id: fileId,
 | 
									_id: fileId,
 | 
				
			||||||
				'metadata.deletedAt': { $exists: false }
 | 
									'metadata.deletedAt': { $exists: false }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,7 +25,7 @@ export const description = `
 | 
				
			||||||
#### 2.ユーザーに認証させる
 | 
					#### 2.ユーザーに認証させる
 | 
				
			||||||
アプリを使ってもらうには、ユーザーにアカウントへのアクセスの許可をもらう必要があります。
 | 
					アプリを使ってもらうには、ユーザーにアカウントへのアクセスの許可をもらう必要があります。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
認証セッションを開始するには、[${config.api_url}/auth/session/generate](#operation/auth/session/generate) へパラメータに appSecret としてシークレットキーを含めたリクエストを送信します。
 | 
					認証セッションを開始するには、[${config.apiUrl}/auth/session/generate](#operation/auth/session/generate) へパラメータに appSecret としてシークレットキーを含めたリクエストを送信します。
 | 
				
			||||||
リクエスト形式はJSONで、メソッドはPOSTです。
 | 
					リクエスト形式はJSONで、メソッドはPOSTです。
 | 
				
			||||||
レスポンスとして認証セッションのトークンや認証フォームのURLが取得できるので、認証フォームのURLをブラウザで表示し、ユーザーにフォームを提示してください。
 | 
					レスポンスとして認証セッションのトークンや認証フォームのURLが取得できるので、認証フォームのURLをブラウザで表示し、ユーザーにフォームを提示してください。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,7 +35,7 @@ export const description = `
 | 
				
			||||||
あなたのアプリがコールバックURLを設定していない場合、ユーザーがあなたのアプリの連携を許可したことを(何らかの方法で(たとえばボタンを押させるなど))確認出来るようにしてください。
 | 
					あなたのアプリがコールバックURLを設定していない場合、ユーザーがあなたのアプリの連携を許可したことを(何らかの方法で(たとえばボタンを押させるなど))確認出来るようにしてください。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#### 3.ユーザートークンを取得する
 | 
					#### 3.ユーザートークンを取得する
 | 
				
			||||||
ユーザーが連携を許可したら、[${config.api_url}/auth/session/userkey](#operation/auth/session/userkey) へリクエストを送信します。
 | 
					ユーザーが連携を許可したら、[${config.apiUrl}/auth/session/userkey](#operation/auth/session/userkey) へリクエストを送信します。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
上手くいけば、認証したユーザーのユーザートークンがレスポンスとして取得できます。おめでとうございます!
 | 
					上手くいけば、認証したユーザーのユーザートークンがレスポンスとして取得できます。おめでとうございます!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,7 +23,7 @@ export function genOpenapiSpec(lang = 'ja-JP') {
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		servers: [{
 | 
							servers: [{
 | 
				
			||||||
			url: config.api_url
 | 
								url: config.apiUrl
 | 
				
			||||||
		}],
 | 
							}],
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		paths: {} as any,
 | 
							paths: {} as any,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -179,7 +179,7 @@ router.get('/dc/cb', async ctx => {
 | 
				
			||||||
				url: 'https://discordapp.com/api/users/@me',
 | 
									url: 'https://discordapp.com/api/users/@me',
 | 
				
			||||||
				headers: {
 | 
									headers: {
 | 
				
			||||||
					'Authorization': `Bearer ${accessToken}`,
 | 
										'Authorization': `Bearer ${accessToken}`,
 | 
				
			||||||
					'User-Agent': config.user_agent
 | 
										'User-Agent': config.userAgent
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}, (err, response, body) => {
 | 
								}, (err, response, body) => {
 | 
				
			||||||
				if (err)
 | 
									if (err)
 | 
				
			||||||
| 
						 | 
					@ -263,7 +263,7 @@ router.get('/dc/cb', async ctx => {
 | 
				
			||||||
				url: 'https://discordapp.com/api/users/@me',
 | 
									url: 'https://discordapp.com/api/users/@me',
 | 
				
			||||||
				headers: {
 | 
									headers: {
 | 
				
			||||||
					'Authorization': `Bearer ${accessToken}`,
 | 
										'Authorization': `Bearer ${accessToken}`,
 | 
				
			||||||
					'User-Agent': config.user_agent
 | 
										'User-Agent': config.userAgent
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}, (err, response, body) => {
 | 
								}, (err, response, body) => {
 | 
				
			||||||
				if (err)
 | 
									if (err)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -171,7 +171,7 @@ router.get('/gh/cb', async ctx => {
 | 
				
			||||||
				headers: {
 | 
									headers: {
 | 
				
			||||||
					'Accept': 'application/vnd.github.v3+json',
 | 
										'Accept': 'application/vnd.github.v3+json',
 | 
				
			||||||
					'Authorization': `bearer ${accessToken}`,
 | 
										'Authorization': `bearer ${accessToken}`,
 | 
				
			||||||
					'User-Agent': config.user_agent
 | 
										'User-Agent': config.userAgent
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}, (err, response, body) => {
 | 
								}, (err, response, body) => {
 | 
				
			||||||
				if (err)
 | 
									if (err)
 | 
				
			||||||
| 
						 | 
					@ -234,7 +234,7 @@ router.get('/gh/cb', async ctx => {
 | 
				
			||||||
				headers: {
 | 
									headers: {
 | 
				
			||||||
					'Accept': 'application/vnd.github.v3+json',
 | 
										'Accept': 'application/vnd.github.v3+json',
 | 
				
			||||||
					'Authorization': `bearer ${accessToken}`,
 | 
										'Authorization': `bearer ${accessToken}`,
 | 
				
			||||||
					'User-Agent': config.user_agent
 | 
										'User-Agent': config.userAgent
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}, (err, response, body) => {
 | 
								}, (err, response, body) => {
 | 
				
			||||||
				if (err)
 | 
									if (err)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -72,7 +72,7 @@ async function fetch(url: string, path: string) {
 | 
				
			||||||
			proxy: config.proxy,
 | 
								proxy: config.proxy,
 | 
				
			||||||
			timeout: 10 * 1000,
 | 
								timeout: 10 * 1000,
 | 
				
			||||||
			headers: {
 | 
								headers: {
 | 
				
			||||||
				'User-Agent': config.user_agent
 | 
									'User-Agent': config.userAgent
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -79,13 +79,13 @@ router.get('/*/*', async ctx => {
 | 
				
			||||||
	showdown.extension('wsUrlExtension', () => ({
 | 
						showdown.extension('wsUrlExtension', () => ({
 | 
				
			||||||
		type: 'output',
 | 
							type: 'output',
 | 
				
			||||||
		regex: /%WS_URL%/g,
 | 
							regex: /%WS_URL%/g,
 | 
				
			||||||
		replace: config.ws_url
 | 
							replace: config.wsUrl
 | 
				
			||||||
	}));
 | 
						}));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	showdown.extension('apiUrlExtension', () => ({
 | 
						showdown.extension('apiUrlExtension', () => ({
 | 
				
			||||||
		type: 'output',
 | 
							type: 'output',
 | 
				
			||||||
		regex: /%API_URL%/g,
 | 
							regex: /%API_URL%/g,
 | 
				
			||||||
		replace: config.api_url
 | 
							replace: config.apiUrl
 | 
				
			||||||
	}));
 | 
						}));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const conv = new showdown.Converter({
 | 
						const conv = new showdown.Converter({
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,7 +58,7 @@ export default async (
 | 
				
			||||||
			proxy: config.proxy,
 | 
								proxy: config.proxy,
 | 
				
			||||||
			timeout: 10 * 1000,
 | 
								timeout: 10 * 1000,
 | 
				
			||||||
			headers: {
 | 
								headers: {
 | 
				
			||||||
				'User-Agent': config.user_agent
 | 
									'User-Agent': config.userAgent
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue