mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-11-26 07:55:14 +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.hostname = url.hostname;
|
||||
mixin.scheme = url.protocol.replace(/:$/, '');
|
||||
mixin.ws_scheme = mixin.scheme.replace('http', 'ws');
|
||||
mixin.ws_url = `${mixin.ws_scheme}://${mixin.host}`;
|
||||
mixin.api_url = `${mixin.scheme}://${mixin.host}/api`;
|
||||
mixin.auth_url = `${mixin.scheme}://${mixin.host}/auth`;
|
||||
mixin.dev_url = `${mixin.scheme}://${mixin.host}/dev`;
|
||||
mixin.docs_url = `${mixin.scheme}://${mixin.host}/docs`;
|
||||
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})`;
|
||||
mixin.wsScheme = mixin.scheme.replace('http', 'ws');
|
||||
mixin.wsUrl = `${mixin.wsScheme}://${mixin.host}`;
|
||||
mixin.apiUrl = `${mixin.scheme}://${mixin.host}/api`;
|
||||
mixin.authUrl = `${mixin.scheme}://${mixin.host}/auth`;
|
||||
mixin.driveUrl = `${mixin.scheme}://${mixin.host}/files`;
|
||||
mixin.userAgent = `Misskey/${pkg.version} (${config.url})`;
|
||||
|
||||
if (config.autoAdmin == null) config.autoAdmin = false;
|
||||
|
||||
|
|
|
@ -49,16 +49,12 @@ export type Mixin = {
|
|||
host: string;
|
||||
hostname: string;
|
||||
scheme: string;
|
||||
ws_scheme: string;
|
||||
api_url: string;
|
||||
ws_url: string;
|
||||
auth_url: string;
|
||||
docs_url: string;
|
||||
stats_url: string;
|
||||
status_url: string;
|
||||
dev_url: string;
|
||||
drive_url: string;
|
||||
user_agent: string;
|
||||
wsScheme: string;
|
||||
apiUrl: string;
|
||||
wsUrl: string;
|
||||
authUrl: string;
|
||||
driveUrl: string;
|
||||
userAgent: string;
|
||||
};
|
||||
|
||||
export type Config = Source & Mixin;
|
||||
|
|
|
@ -14,9 +14,9 @@ export default function(file: IDriveFile, thumbnail = false): string {
|
|||
}
|
||||
} else {
|
||||
if (thumbnail) {
|
||||
return `${config.drive_url}/${file._id}?thumbnail`;
|
||||
return `${config.driveUrl}/${file._id}?thumbnail`;
|
||||
} 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;
|
||||
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
|
||||
? `${config.drive_url}/${_app.icon}`
|
||||
: `${config.drive_url}/app-default.jpg`;
|
||||
? `${config.driveUrl}/${_app.icon}`
|
||||
: `${config.driveUrl}/app-default.jpg`;
|
||||
|
||||
if (me) {
|
||||
// 既に連携しているか
|
||||
|
|
|
@ -350,7 +350,7 @@ export const pack = (
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -45,7 +45,7 @@ export default (user: ILocalUser, url: string, object: any) => new Promise(async
|
|||
timeout,
|
||||
headers: {
|
||||
'Host': host,
|
||||
'User-Agent': config.user_agent,
|
||||
'User-Agent': config.userAgent,
|
||||
'Content-Type': 'application/activity+json',
|
||||
'Digest': `SHA-256=${hash}`
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ export default class Resolver {
|
|||
proxy: config.proxy,
|
||||
timeout: this.timeout,
|
||||
headers: {
|
||||
'User-Agent': config.user_agent,
|
||||
'User-Agent': config.userAgent,
|
||||
Accept: 'application/activity+json, application/ld+json'
|
||||
},
|
||||
json: true
|
||||
|
|
|
@ -52,6 +52,6 @@ export default define(meta, async (ps) => {
|
|||
|
||||
return {
|
||||
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 }
|
||||
});
|
||||
} else if (ps.url) {
|
||||
const isInternalStorageUrl = ps.url.startsWith(config.drive_url);
|
||||
const isInternalStorageUrl = ps.url.startsWith(config.driveUrl);
|
||||
if (isInternalStorageUrl) {
|
||||
// Extract file ID from url
|
||||
// e.g.
|
||||
// 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({
|
||||
_id: fileId,
|
||||
'metadata.deletedAt': { $exists: false }
|
||||
|
|
|
@ -25,7 +25,7 @@ export const description = `
|
|||
#### 2.ユーザーに認証させる
|
||||
アプリを使ってもらうには、ユーザーにアカウントへのアクセスの許可をもらう必要があります。
|
||||
|
||||
認証セッションを開始するには、[${config.api_url}/auth/session/generate](#operation/auth/session/generate) へパラメータに appSecret としてシークレットキーを含めたリクエストを送信します。
|
||||
認証セッションを開始するには、[${config.apiUrl}/auth/session/generate](#operation/auth/session/generate) へパラメータに appSecret としてシークレットキーを含めたリクエストを送信します。
|
||||
リクエスト形式はJSONで、メソッドはPOSTです。
|
||||
レスポンスとして認証セッションのトークンや認証フォームのURLが取得できるので、認証フォームのURLをブラウザで表示し、ユーザーにフォームを提示してください。
|
||||
|
||||
|
@ -35,7 +35,7 @@ export const description = `
|
|||
あなたのアプリがコールバックURLを設定していない場合、ユーザーがあなたのアプリの連携を許可したことを(何らかの方法で(たとえばボタンを押させるなど))確認出来るようにしてください。
|
||||
|
||||
#### 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: [{
|
||||
url: config.api_url
|
||||
url: config.apiUrl
|
||||
}],
|
||||
|
||||
paths: {} as any,
|
||||
|
|
|
@ -179,7 +179,7 @@ router.get('/dc/cb', async ctx => {
|
|||
url: 'https://discordapp.com/api/users/@me',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${accessToken}`,
|
||||
'User-Agent': config.user_agent
|
||||
'User-Agent': config.userAgent
|
||||
}
|
||||
}, (err, response, body) => {
|
||||
if (err)
|
||||
|
@ -263,7 +263,7 @@ router.get('/dc/cb', async ctx => {
|
|||
url: 'https://discordapp.com/api/users/@me',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${accessToken}`,
|
||||
'User-Agent': config.user_agent
|
||||
'User-Agent': config.userAgent
|
||||
}
|
||||
}, (err, response, body) => {
|
||||
if (err)
|
||||
|
|
|
@ -171,7 +171,7 @@ router.get('/gh/cb', async ctx => {
|
|||
headers: {
|
||||
'Accept': 'application/vnd.github.v3+json',
|
||||
'Authorization': `bearer ${accessToken}`,
|
||||
'User-Agent': config.user_agent
|
||||
'User-Agent': config.userAgent
|
||||
}
|
||||
}, (err, response, body) => {
|
||||
if (err)
|
||||
|
@ -234,7 +234,7 @@ router.get('/gh/cb', async ctx => {
|
|||
headers: {
|
||||
'Accept': 'application/vnd.github.v3+json',
|
||||
'Authorization': `bearer ${accessToken}`,
|
||||
'User-Agent': config.user_agent
|
||||
'User-Agent': config.userAgent
|
||||
}
|
||||
}, (err, response, body) => {
|
||||
if (err)
|
||||
|
|
|
@ -72,7 +72,7 @@ async function fetch(url: string, path: string) {
|
|||
proxy: config.proxy,
|
||||
timeout: 10 * 1000,
|
||||
headers: {
|
||||
'User-Agent': config.user_agent
|
||||
'User-Agent': config.userAgent
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -79,13 +79,13 @@ router.get('/*/*', async ctx => {
|
|||
showdown.extension('wsUrlExtension', () => ({
|
||||
type: 'output',
|
||||
regex: /%WS_URL%/g,
|
||||
replace: config.ws_url
|
||||
replace: config.wsUrl
|
||||
}));
|
||||
|
||||
showdown.extension('apiUrlExtension', () => ({
|
||||
type: 'output',
|
||||
regex: /%API_URL%/g,
|
||||
replace: config.api_url
|
||||
replace: config.apiUrl
|
||||
}));
|
||||
|
||||
const conv = new showdown.Converter({
|
||||
|
|
|
@ -58,7 +58,7 @@ export default async (
|
|||
proxy: config.proxy,
|
||||
timeout: 10 * 1000,
|
||||
headers: {
|
||||
'User-Agent': config.user_agent
|
||||
'User-Agent': config.userAgent
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue