mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-12-22 00:10:14 +00:00
自分宛ての投稿をタイムラインで見れるように
This commit is contained in:
parent
cda3635d97
commit
32afe77a26
8 changed files with 55 additions and 32 deletions
|
@ -167,6 +167,7 @@ common:
|
|||
local: "ローカル"
|
||||
hybrid: "ソーシャル"
|
||||
global: "グローバル"
|
||||
mentions: "あなた宛て"
|
||||
notifications: "通知"
|
||||
list: "リスト"
|
||||
swap-left: "左に移動"
|
||||
|
@ -913,6 +914,7 @@ desktop/views/components/timeline.vue:
|
|||
local: "ローカル"
|
||||
hybrid: "ソーシャル"
|
||||
global: "グローバル"
|
||||
mentions: "あなた宛て"
|
||||
list: "リスト"
|
||||
|
||||
desktop/views/components/ui.header.vue:
|
||||
|
@ -1314,6 +1316,7 @@ mobile/views/pages/home.vue:
|
|||
local: "ローカル"
|
||||
hybrid: "ソーシャル"
|
||||
global: "グローバル"
|
||||
mentions: "あなた宛て"
|
||||
|
||||
mobile/views/pages/tag.vue:
|
||||
no-posts-found: "ハッシュタグ「{}」が付けられた投稿は見つかりませんでした。"
|
||||
|
|
|
@ -48,6 +48,7 @@ export default Vue.extend({
|
|||
case 'local': return (this as any).os.streams.localTimelineStream;
|
||||
case 'hybrid': return (this as any).os.streams.hybridTimelineStream;
|
||||
case 'global': return (this as any).os.streams.globalTimelineStream;
|
||||
case 'mentions': return (this as any).os.stream;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -57,6 +58,7 @@ export default Vue.extend({
|
|||
case 'local': return 'notes/local-timeline';
|
||||
case 'hybrid': return 'notes/hybrid-timeline';
|
||||
case 'global': return 'notes/global-timeline';
|
||||
case 'mentions': return 'notes/mentions';
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -69,7 +71,7 @@ export default Vue.extend({
|
|||
this.connection = this.stream.getConnection();
|
||||
this.connectionId = this.stream.use();
|
||||
|
||||
this.connection.on('note', this.onNote);
|
||||
this.connection.on(this.src == 'mentions' ? 'mention' : 'note', this.onNote);
|
||||
if (this.src == 'home') {
|
||||
this.connection.on('follow', this.onChangeFollowing);
|
||||
this.connection.on('unfollow', this.onChangeFollowing);
|
||||
|
@ -81,7 +83,7 @@ export default Vue.extend({
|
|||
},
|
||||
|
||||
beforeDestroy() {
|
||||
this.connection.off('note', this.onNote);
|
||||
this.connection.off(this.src == 'mentions' ? 'mention' : 'note', this.onNote);
|
||||
if (this.src == 'home') {
|
||||
this.connection.off('follow', this.onChangeFollowing);
|
||||
this.connection.off('unfollow', this.onChangeFollowing);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<span :data-active="src == 'local'" @click="src = 'local'" v-if="enableLocalTimeline">%fa:R comments% %i18n:@local%</span>
|
||||
<span :data-active="src == 'hybrid'" @click="src = 'hybrid'" v-if="enableLocalTimeline">%fa:share-alt% %i18n:@hybrid%</span>
|
||||
<span :data-active="src == 'global'" @click="src = 'global'">%fa:globe% %i18n:@global%</span>
|
||||
<span :data-active="src == 'mentions'" @click="src = 'mentions'">%fa:at% %i18n:@mentions%</span>
|
||||
<span :data-active="src == 'list'" @click="src = 'list'" v-if="list">%fa:list% {{ list.title }}</span>
|
||||
<button @click="chooseList" title="%i18n:@list%">%fa:list%</button>
|
||||
</header>
|
||||
|
@ -12,6 +13,7 @@
|
|||
<x-core v-if="src == 'local'" ref="tl" key="local" src="local"/>
|
||||
<x-core v-if="src == 'hybrid'" ref="tl" key="hybrid" src="hybrid"/>
|
||||
<x-core v-if="src == 'global'" ref="tl" key="global" src="global"/>
|
||||
<x-core v-if="src == 'mentions'" ref="tl" key="mentions" src="mentions"/>
|
||||
<mk-user-list-timeline v-if="src == 'list'" ref="tl" :key="list.id" :list="list"/>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -47,6 +47,7 @@ export default Vue.extend({
|
|||
case 'local': return (this as any).os.streams.localTimelineStream;
|
||||
case 'hybrid': return (this as any).os.streams.hybridTimelineStream;
|
||||
case 'global': return (this as any).os.streams.globalTimelineStream;
|
||||
case 'mentions': return (this as any).os.stream;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -56,6 +57,7 @@ export default Vue.extend({
|
|||
case 'local': return 'notes/local-timeline';
|
||||
case 'hybrid': return 'notes/hybrid-timeline';
|
||||
case 'global': return 'notes/global-timeline';
|
||||
case 'mentions': return 'notes/mentions';
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -68,7 +70,7 @@ export default Vue.extend({
|
|||
this.connection = this.stream.getConnection();
|
||||
this.connectionId = this.stream.use();
|
||||
|
||||
this.connection.on('note', this.onNote);
|
||||
this.connection.on(this.src == 'mentions' ? 'mention' : 'note', this.onNote);
|
||||
if (this.src == 'home') {
|
||||
this.connection.on('follow', this.onChangeFollowing);
|
||||
this.connection.on('unfollow', this.onChangeFollowing);
|
||||
|
@ -78,7 +80,7 @@ export default Vue.extend({
|
|||
},
|
||||
|
||||
beforeDestroy() {
|
||||
this.connection.off('note', this.onNote);
|
||||
this.connection.off(this.src == 'mentions' ? 'mention' : 'note', this.onNote);
|
||||
if (this.src == 'home') {
|
||||
this.connection.off('follow', this.onChangeFollowing);
|
||||
this.connection.off('unfollow', this.onChangeFollowing);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<span v-if="src == 'local'">%fa:R comments%%i18n:@local%</span>
|
||||
<span v-if="src == 'hybrid'">%fa:share-alt%%i18n:@hybrid%</span>
|
||||
<span v-if="src == 'global'">%fa:globe%%i18n:@global%</span>
|
||||
<span v-if="src == 'mentions'">%fa:at%%i18n:@mentions%</span>
|
||||
<span v-if="src == 'list'">%fa:list%{{ list.title }}</span>
|
||||
</span>
|
||||
<span style="margin-left:8px">
|
||||
|
@ -27,6 +28,7 @@
|
|||
<span :data-active="src == 'local'" @click="src = 'local'" v-if="enableLocalTimeline">%fa:R comments% %i18n:@local%</span>
|
||||
<span :data-active="src == 'hybrid'" @click="src = 'hybrid'" v-if="enableLocalTimeline">%fa:share-alt% %i18n:@hybrid%</span>
|
||||
<span :data-active="src == 'global'" @click="src = 'global'">%fa:globe% %i18n:@global%</span>
|
||||
<span :data-active="src == 'mentions'" @click="src = 'mentions'">%fa:at% %i18n:@mentions%</span>
|
||||
<template v-if="lists">
|
||||
<span v-for="l in lists" :data-active="src == 'list' && list == l" @click="src = 'list'; list = l" :key="l.id">%fa:list% {{ l.title }}</span>
|
||||
</template>
|
||||
|
@ -39,6 +41,7 @@
|
|||
<x-tl v-if="src == 'local'" ref="tl" key="local" src="local"/>
|
||||
<x-tl v-if="src == 'hybrid'" ref="tl" key="hybrid" src="hybrid"/>
|
||||
<x-tl v-if="src == 'global'" ref="tl" key="global" src="global"/>
|
||||
<x-tl v-if="src == 'mentions'" ref="tl" key="mentions" src="mentions"/>
|
||||
<mk-user-list-timeline v-if="src == 'list'" ref="tl" :key="list.id" :list="list"/>
|
||||
</div>
|
||||
</main>
|
||||
|
|
|
@ -17,6 +17,8 @@ import Following from './following';
|
|||
const Note = db.get<INote>('notes');
|
||||
Note.createIndex('uri', { sparse: true, unique: true });
|
||||
Note.createIndex('userId');
|
||||
Note.createIndex('mentions');
|
||||
Note.createIndex('visibleUserIds');
|
||||
Note.createIndex('tagsLower');
|
||||
Note.createIndex('_files.contentType');
|
||||
Note.createIndex({
|
||||
|
|
|
@ -3,6 +3,7 @@ import Note from '../../../../models/note';
|
|||
import { getFriendIds } from '../../common/get-friends';
|
||||
import { pack } from '../../../../models/note';
|
||||
import { ILocalUser } from '../../../../models/user';
|
||||
import getParams from '../../get-params';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
|
@ -10,42 +11,48 @@ export const meta = {
|
|||
'en-US': 'Get mentions of myself.'
|
||||
},
|
||||
|
||||
requireCredential: true
|
||||
requireCredential: true,
|
||||
|
||||
params: {
|
||||
following: $.bool.optional.note({
|
||||
default: false
|
||||
}),
|
||||
|
||||
limit: $.num.optional.range(1, 100).note({
|
||||
default: 10
|
||||
}),
|
||||
|
||||
sinceId: $.type(ID).optional.note({
|
||||
}),
|
||||
|
||||
untilId: $.type(ID).optional.note({
|
||||
}),
|
||||
}
|
||||
};
|
||||
|
||||
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
||||
// Get 'following' parameter
|
||||
const [following = false, followingError] =
|
||||
$.bool.optional.get(params.following);
|
||||
if (followingError) return rej('invalid following param');
|
||||
|
||||
// Get 'limit' parameter
|
||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||
if (limitErr) return rej('invalid limit param');
|
||||
|
||||
// Get 'sinceId' parameter
|
||||
const [sinceId, sinceIdErr] = $.type(ID).optional.get(params.sinceId);
|
||||
if (sinceIdErr) return rej('invalid sinceId param');
|
||||
|
||||
// Get 'untilId' parameter
|
||||
const [untilId, untilIdErr] = $.type(ID).optional.get(params.untilId);
|
||||
if (untilIdErr) return rej('invalid untilId param');
|
||||
const [ps, psErr] = getParams(meta, params);
|
||||
if (psErr) throw psErr;
|
||||
|
||||
// Check if both of sinceId and untilId is specified
|
||||
if (sinceId && untilId) {
|
||||
if (ps.sinceId && ps.untilId) {
|
||||
return rej('cannot set sinceId and untilId');
|
||||
}
|
||||
|
||||
// Construct query
|
||||
const query = {
|
||||
mentions: user._id
|
||||
$or: [{
|
||||
mentions: user._id
|
||||
}, {
|
||||
visibleUserIds: user._id
|
||||
}]
|
||||
} as any;
|
||||
|
||||
const sort = {
|
||||
_id: -1
|
||||
};
|
||||
|
||||
if (following) {
|
||||
if (ps.following) {
|
||||
const followingIds = await getFriendIds(user._id);
|
||||
|
||||
query.userId = {
|
||||
|
@ -53,26 +60,24 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
|
|||
};
|
||||
}
|
||||
|
||||
if (sinceId) {
|
||||
if (ps.sinceId) {
|
||||
sort._id = 1;
|
||||
query._id = {
|
||||
$gt: sinceId
|
||||
$gt: ps.sinceId
|
||||
};
|
||||
} else if (untilId) {
|
||||
} else if (ps.untilId) {
|
||||
query._id = {
|
||||
$lt: untilId
|
||||
$lt: ps.untilId
|
||||
};
|
||||
}
|
||||
|
||||
// Issue query
|
||||
const mentions = await Note
|
||||
.find(query, {
|
||||
limit: limit,
|
||||
limit: ps.limit,
|
||||
sort: sort
|
||||
});
|
||||
|
||||
// Serialize
|
||||
res(await Promise.all(mentions.map(async mention =>
|
||||
await pack(mention, user)
|
||||
)));
|
||||
res(await Promise.all(mentions.map(mention => pack(mention, user))));
|
||||
});
|
||||
|
|
|
@ -138,6 +138,10 @@ export default async (user: IUser, data: Option, silent = false) => new Promise<
|
|||
|
||||
const mentionedUsers = await extractMentionedUsers(tokens);
|
||||
|
||||
if (data.reply && !user._id.equals(data.reply.userId) && !mentionedUsers.some(u => u._id.equals(data.reply.userId))) {
|
||||
mentionedUsers.push(await User.findOne({ _id: data.reply.userId }));
|
||||
}
|
||||
|
||||
const note = await insertNote(user, data, tags, mentionedUsers);
|
||||
|
||||
res(note);
|
||||
|
|
Loading…
Reference in a new issue