Mastodonのリンクの所有者認証に対応 (#5161)

* Profile metadata を設定できるように

* API desc
This commit is contained in:
MeiMei
2019-07-18 00:11:39 +09:00
committed by syuilo
parent f1a7ab639b
commit ef44eda69e
8 changed files with 92 additions and 4 deletions

View File

@ -77,6 +77,13 @@ export const meta = {
}
},
fields: {
validator: $.optional.arr($.object()).range(1, 4),
desc: {
'ja-JP': 'プロフィール補足情報'
}
},
isLocked: {
validator: $.optional.bool,
desc: {
@ -226,6 +233,14 @@ export default define(meta, async (ps, user, app) => {
profileUpdates.pinnedPageId = null;
}
if (ps.fields) {
profileUpdates.fields = ps.fields
.filter(x => typeof x.name === 'string' && x.name !== '' && typeof x.value === 'string' && x.value !== '')
.map(x => {
return { name: x.name, value: x.value };
});
}
//#region emojis/tags
let emojis = [] as string[];

View File

@ -156,11 +156,17 @@ router.get('/@:user', async (ctx, next) => {
if (user != null) {
const profile = await UserProfiles.findOne(user.id).then(ensure);
const meta = await fetchMeta();
const me = profile.fields
? profile.fields
.filter(filed => filed.value != null && filed.value.match(/^https?:/))
.map(field => field.value)
: [];
await ctx.render('user', {
user, profile,
user, profile, me,
instanceName: meta.name || 'Misskey'
});
ctx.set('Cache-Control', 'public, max-age=180');
ctx.set('Cache-Control', 'public, max-age=30');
} else {
// リモートユーザーなので
await next();

View File

@ -44,3 +44,4 @@ html
<svg viewBox="0 0 50 50">
<path fill=#fb4e4e d="M25.251,6.461c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615V6.461z" />
</svg>
block content

View File

@ -36,3 +36,8 @@ block meta
link(rel='alternate' href=user.uri type='application/activity+json')
if profile.url
link(rel='alternate' href=profile.url type='text/html')
block content
div#me
each m in me
a(rel='me' href=`${m}`) #{m}