Compare commits

..

5 Commits

Author SHA1 Message Date
11f25ea2e7 8.31.0 2018-09-08 06:44:34 +09:00
ef62497777 ActivityPub Outboxの修正とactivity idのURLを実装 (#2662)
* Fix Outbox structure

* Implement activity endpoint

* Use in instead of or

* Use in, addition
2018-09-08 05:24:55 +09:00
2824d8a5b6 Add animation 2018-09-08 04:54:11 +09:00
1c84c0828e 良い感じに 2018-09-08 01:46:01 +09:00
39e4494836 🎨 2018-09-08 01:31:50 +09:00
6 changed files with 112 additions and 78 deletions

View File

@ -1,8 +1,8 @@
{
"name": "misskey",
"author": "syuilo <i@syuilo.com>",
"version": "8.30.0",
"clientVersion": "1.0.9481",
"version": "8.31.0",
"clientVersion": "1.0.9486",
"codename": "nighthike",
"main": "./built/index.js",
"private": true,

View File

@ -4,9 +4,9 @@
<p class="empty" v-else-if="tags.length == 0">%fa:exclamation-circle%%i18n:@empty%</p>
<div v-else>
<vue-word-cloud
:words="tags.map(x => [x.name, x.count])"
:words="tags.slice(0, 20).map(x => [x.name, x.count])"
:color="color"
font-family="Roboto">
:spacing="1">
<template slot-scope="{word, text, weight}">
<div style="cursor: pointer;" :title="weight">
{{ text }}
@ -50,7 +50,7 @@ export default Vue.extend({
const peak = Math.max.apply(null, this.tags.map(x => x.count));
const w = weight / peak;
if (w == 1) {
if (w > 0.9) {
return this.$store.state.device.darkmode ? '#ff4e69' : '#ff4e69';
} else if (w > 0.5) {
return this.$store.state.device.darkmode ? '#3bc4c7' : '#3bc4c7';

View File

@ -1,22 +1,24 @@
<template>
<div class="mk-welcome-timeline">
<div v-for="note in notes">
<mk-avatar class="avatar" :user="note.user" target="_blank"/>
<div class="body">
<header>
<router-link class="name" :to="note.user | userPage" v-user-preview="note.user.id">{{ note.user | userName }}</router-link>
<span class="username">@{{ note.user | acct }}</span>
<div class="info">
<router-link class="created-at" :to="note | notePage">
<mk-time :time="note.createdAt"/>
</router-link>
<transition-group name="ldzpakcixzickvggyixyrhqwjaefknon" tag="div">
<div v-for="note in notes" :key="note.id">
<mk-avatar class="avatar" :user="note.user" target="_blank"/>
<div class="body">
<header>
<router-link class="name" :to="note.user | userPage" v-user-preview="note.user.id">{{ note.user | userName }}</router-link>
<span class="username">@{{ note.user | acct }}</span>
<div class="info">
<router-link class="created-at" :to="note | notePage">
<mk-time :time="note.createdAt"/>
</router-link>
</div>
</header>
<div class="text">
<misskey-flavored-markdown v-if="note.text" :text="note.text"/>
</div>
</header>
<div class="text">
<misskey-flavored-markdown v-if="note.text" :text="note.text"/>
</div>
</div>
</div>
</transition-group>
</div>
</template>
@ -83,64 +85,73 @@ export default Vue.extend({
</script>
<style lang="stylus" scoped>
.ldzpakcixzickvggyixyrhqwjaefknon-enter
.ldzpakcixzickvggyixyrhqwjaefknon-leave-to
opacity 0
transform translateY(-30px)
root(isDark)
background isDark ? #282C37 : #fff
> div
padding 16px
overflow-wrap break-word
font-size .9em
color isDark ? #fff : #4C4C4C
border-bottom 1px solid isDark ? rgba(#000, 0.1) : rgba(#000, 0.05)
> *
transition transform .3s ease, opacity .3s ease
&:after
content ""
display block
clear both
> div
padding 16px
overflow-wrap break-word
font-size .9em
color isDark ? #fff : #4C4C4C
border-bottom 1px solid isDark ? rgba(#000, 0.1) : rgba(#000, 0.05)
> .avatar
display block
float left
position -webkit-sticky
position sticky
top 16px
width 42px
height 42px
border-radius 6px
&:after
content ""
display block
clear both
> .body
float right
width calc(100% - 42px)
padding-left 12px
> .avatar
display block
float left
position -webkit-sticky
position sticky
top 16px
width 42px
height 42px
border-radius 6px
> header
display flex
align-items center
margin-bottom 4px
white-space nowrap
> .body
float right
width calc(100% - 42px)
padding-left 12px
> .name
display block
margin 0 .5em 0 0
padding 0
overflow hidden
font-weight bold
text-overflow ellipsis
color isDark ? #fff : #627079
> header
display flex
align-items center
margin-bottom 4px
white-space nowrap
> .username
margin 0 .5em 0 0
color isDark ? #606984 : #ccc
> .name
display block
margin 0 .5em 0 0
padding 0
overflow hidden
font-weight bold
text-overflow ellipsis
color isDark ? #fff : #627079
> .info
margin-left auto
font-size 0.9em
> .username
margin 0 .5em 0 0
color isDark ? #606984 : #ccc
> .created-at
color isDark ? #606984 : #c0c0c0
> .info
margin-left auto
font-size 0.9em
> .text
text-align left
> .created-at
color isDark ? #606984 : #c0c0c0
> .text
text-align left
.mk-welcome-timeline[data-darkmode]
root(true)

View File

@ -5,7 +5,7 @@ export default (object: any, note: INote) => {
const attributedTo = `${config.url}/users/${note.userId}`;
return {
id: `${config.url}/notes/${note._id}`,
id: `${config.url}/notes/${note._id}/activity`,
actor: `${config.url}/users/${note.userId}`,
type: 'Announce',
published: note.createdAt.toISOString(),

View File

@ -10,7 +10,7 @@ import User, { isLocalUser, ILocalUser, IUser } from '../models/user';
import renderNote from '../remote/activitypub/renderer/note';
import renderKey from '../remote/activitypub/renderer/key';
import renderPerson from '../remote/activitypub/renderer/person';
import Outbox from './activitypub/outbox';
import Outbox, { packActivity } from './activitypub/outbox';
import Followers from './activitypub/followers';
import Following from './activitypub/following';
@ -77,6 +77,22 @@ router.get('/notes/:note', async (ctx, next) => {
setResponseType(ctx);
});
// note activity
router.get('/notes/:note/activity', async ctx => {
const note = await Note.findOne({
_id: new mongo.ObjectID(ctx.params.note),
visibility: { $in: ['public', 'home'] }
});
if (note === null) {
ctx.status = 404;
return;
}
ctx.body = pack(await packActivity(note));
setResponseType(ctx);
});
// outbox
router.get('/users/:user/outbox', Outbox);

View File

@ -8,8 +8,10 @@ import renderOrderedCollection from '../../remote/activitypub/renderer/ordered-c
import renderOrderedCollectionPage from '../../remote/activitypub/renderer/ordered-collection-page';
import { setResponseType } from '../activitypub';
import Note from '../../models/note';
import Note, { INote } from '../../models/note';
import renderNote from '../../remote/activitypub/renderer/note';
import renderCreate from '../../remote/activitypub/renderer/create';
import renderAnnounce from '../../remote/activitypub/renderer/announce';
import { countIf } from '../../prelude/array';
export default async (ctx: Router.IRouterContext) => {
@ -53,15 +55,7 @@ export default async (ctx: Router.IRouterContext) => {
const query = {
userId: user._id,
$and: [{
$or: [ { visibility: 'public' }, { visibility: 'home' } ]
}, { // exclude renote, but include quote
$or: [{
text: { $ne: null }
}, {
fileIds: { $ne: [] }
}]
}]
visibility: { $in: ['public', 'home'] }
} as any;
if (sinceId) {
@ -85,10 +79,10 @@ export default async (ctx: Router.IRouterContext) => {
if (sinceId) notes.reverse();
const renderedNotes = await Promise.all(notes.map(note => renderNote(note, false)));
const activities = await Promise.all(notes.map(note => packActivity(note)));
const rendered = renderOrderedCollectionPage(
`${partOf}?page=true${sinceId ? `&since_id=${sinceId}` : ''}${untilId ? `&until_id=${untilId}` : ''}`,
user.notesCount, renderedNotes, partOf,
user.notesCount, activities, partOf,
notes.length > 0 ? `${partOf}?page=true&since_id=${notes[0]._id}` : null,
notes.length > 0 ? `${partOf}?page=true&until_id=${notes[notes.length - 1]._id}` : null
);
@ -105,3 +99,16 @@ export default async (ctx: Router.IRouterContext) => {
setResponseType(ctx);
}
};
/**
* Pack Create<Note> or Announce Activity
* @param note Note
*/
export async function packActivity(note: INote): Promise<object> {
if (note.renoteId && note.text == null) {
const renote = await Note.findOne(note.renoteId);
return renderAnnounce(renote.uri ? renote.uri : `${config.url}/notes/${renote._id}`, note);
}
return renderCreate(await renderNote(note, false), note);
}