1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-10-30 23:01:48 +09:00

RENAME: reply_to -> reply

This commit is contained in:
こぴなたみぽ 2017-11-01 10:22:40 +09:00
parent d6a8e6b7c2
commit 60a7640eb1
25 changed files with 60 additions and 60 deletions

View File

@ -19,7 +19,7 @@ module.exports = params => new Promise(async (res, rej) => {
.aggregate([
{ $project: {
repost_id: '$repost_id',
reply_to_id: '$reply_to_id',
reply_id: '$reply_id',
created_at: { $add: ['$created_at', 9 * 60 * 60 * 1000] } // Convert into JST
}},
{ $project: {
@ -34,7 +34,7 @@ module.exports = params => new Promise(async (res, rej) => {
then: 'repost',
else: {
$cond: {
if: { $ne: ['$reply_to_id', null] },
if: { $ne: ['$reply_id', null] },
then: 'reply',
else: 'post'
}

View File

@ -26,7 +26,7 @@ module.exports = (params) => new Promise(async (res, rej) => {
const datas = await Post
.aggregate([
{ $match: { reply_to: post._id } },
{ $match: { reply: post._id } },
{ $project: {
created_at: { $add: ['$created_at', 9 * 60 * 60 * 1000] } // Convert into JST
}},

View File

@ -40,7 +40,7 @@ module.exports = (params) => new Promise(async (res, rej) => {
{ $match: { user_id: user._id } },
{ $project: {
repost_id: '$repost_id',
reply_to_id: '$reply_to_id',
reply_id: '$reply_id',
created_at: { $add: ['$created_at', 9 * 60 * 60 * 1000] } // Convert into JST
}},
{ $project: {
@ -55,7 +55,7 @@ module.exports = (params) => new Promise(async (res, rej) => {
then: 'repost',
else: {
$cond: {
if: { $ne: ['$reply_to_id', null] },
if: { $ne: ['$reply_id', null] },
then: 'reply',
else: 'post'
}

View File

@ -34,7 +34,7 @@ module.exports = (params) => new Promise(async (res, rej) => {
{ $match: { user_id: user._id } },
{ $project: {
repost_id: '$repost_id',
reply_to_id: '$reply_to_id',
reply_id: '$reply_id',
created_at: { $add: ['$created_at', 9 * 60 * 60 * 1000] } // Convert into JST
}},
{ $project: {
@ -49,7 +49,7 @@ module.exports = (params) => new Promise(async (res, rej) => {
then: 'repost',
else: {
$cond: {
if: { $ne: ['$reply_to_id', null] },
if: { $ne: ['$reply_id', null] },
then: 'reply',
else: 'post'
}

View File

@ -62,7 +62,7 @@ module.exports = (params) => new Promise(async (res, rej) => {
}
if (reply != undefined) {
query.reply_to_id = reply ? { $exists: true, $ne: null } : null;
query.reply_id = reply ? { $exists: true, $ne: null } : null;
}
if (repost != undefined) {

View File

@ -49,13 +49,13 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
return;
}
if (p.reply_to_id) {
await get(p.reply_to_id);
if (p.reply_id) {
await get(p.reply_id);
}
}
if (post.reply_to_id) {
await get(post.reply_to_id);
if (post.reply_id) {
await get(post.reply_id);
}
// Serialize

View File

@ -103,9 +103,9 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => {
}
}
// Get 'in_reply_to_post_id' parameter
const [inReplyToPostId, inReplyToPostIdErr] = $(params.reply_to_id).optional.id().$;
if (inReplyToPostIdErr) return rej('invalid in_reply_to_post_id');
// Get 'in_reply_post_id' parameter
const [inReplyToPostId, inReplyToPostIdErr] = $(params.reply_id).optional.id().$;
if (inReplyToPostIdErr) return rej('invalid in_reply_post_id');
let inReplyToPost: IPost = null;
if (inReplyToPostId !== undefined) {
@ -192,7 +192,7 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => {
if (user.latest_post) {
if (deepEqual({
text: user.latest_post.text,
reply: user.latest_post.reply_to_id ? user.latest_post.reply_to_id.toString() : null,
reply: user.latest_post.reply_id ? user.latest_post.reply_id.toString() : null,
repost: user.latest_post.repost_id ? user.latest_post.repost_id.toString() : null,
media_ids: (user.latest_post.media_ids || []).map(id => id.toString())
}, {
@ -211,7 +211,7 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => {
channel_id: channel ? channel._id : undefined,
index: channel ? channel.index + 1 : undefined,
media_ids: files ? files.map(file => file._id) : undefined,
reply_to_id: inReplyToPost ? inReplyToPost._id : undefined,
reply_id: inReplyToPost ? inReplyToPost._id : undefined,
repost_id: repost ? repost._id : undefined,
poll: poll,
text: text,

View File

@ -40,7 +40,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Issue query
const replies = await Post
.find({ reply_to_id: post._id }, {
.find({ reply_id: post._id }, {
limit: limit,
skip: offset,
sort: {

View File

@ -48,7 +48,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
} as any;
if (reply != undefined) {
query.reply_to_id = reply ? { $exists: true, $ne: null } : null;
query.reply_id = reply ? { $exists: true, $ne: null } : null;
}
if (repost != undefined) {

View File

@ -27,7 +27,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
// Fetch recent posts
const recentPosts = await Post.find({
user_id: user._id,
reply_to_id: {
reply_id: {
$exists: true,
$ne: null
}
@ -38,7 +38,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
limit: 1000,
fields: {
_id: false,
reply_to_id: true
reply_id: true
}
});
@ -49,7 +49,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
const replyTargetPosts = await Post.find({
_id: {
$in: recentPosts.map(p => p.reply_to_id)
$in: recentPosts.map(p => p.reply_id)
},
user_id: {
$ne: user._id

View File

@ -85,7 +85,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
}
if (!includeReplies) {
query.reply_to_id = null;
query.reply_id = null;
}
if (withMedia) {

View File

@ -13,7 +13,7 @@ export type IPost = {
channel_id: mongo.ObjectID;
created_at: Date;
media_ids: mongo.ObjectID[];
reply_to_id: mongo.ObjectID;
reply_id: mongo.ObjectID;
repost_id: mongo.ObjectID;
poll: {}; // todo
text: string;

View File

@ -123,9 +123,9 @@ const self = (
});
_post.next = next ? next._id : null;
if (_post.reply_to_id) {
if (_post.reply_id) {
// Populate reply to post
_post.reply_to = await self(_post.reply_to_id, meId, {
_post.reply = await self(_post.reply_id, meId, {
detail: false
});
}

View File

@ -22,9 +22,9 @@ const summarize = (post: any): string => {
}
// 返信のとき
if (post.reply_to_id) {
if (post.reply_to) {
summary += ` RE: ${summarize(post.reply_to)}`;
if (post.reply_id) {
if (post.reply) {
summary += ` RE: ${summarize(post.reply)}`;
} else {
summary += ' RE: ...';
}

View File

@ -52,11 +52,11 @@ block content
td Number
td 返信数
tr.optional
td reply_to
td reply
td: a(href='./post', target='_blank') Post
td 返信先の投稿
tr.nullable
td reply_to_id
td reply_id
td ID
td 返信先の投稿のID
tr.optional
@ -90,7 +90,7 @@ block content
{
"created_at": "2016-12-10T00:28:50.114Z",
"media_ids": null,
"reply_to_id": "584a16b15860fc52320137e3",
"reply_id": "584a16b15860fc52320137e3",
"repost_id": null,
"text": "小日向美穂だぞ!",
"user_id": "5848bf7764e572683f4402f8",
@ -117,10 +117,10 @@ block content
"is_following": true,
"is_followed": true
},
"reply_to": {
"reply": {
"created_at": "2016-12-09T02:28:01.563Z",
"media_ids": null,
"reply_to_id": "5849d35e547e4249be329884",
"reply_id": "5849d35e547e4249be329884",
"repost_id": null,
"text": "アイコン小日向美穂?",
"user_id": "57d01a501fdf2d07be417afe",

View File

@ -96,7 +96,7 @@
<span>ID:<i>{ post.user.username }</i></span>
</header>
<div>
<a if={ post.reply_to }>&gt;&gt;{ post.reply_to.index }</a>
<a if={ post.reply }>&gt;&gt;{ post.reply.index }</a>
{ post.text }
<div class="media" if={ post.media }>
<virtual each={ file in post.media }>
@ -208,7 +208,7 @@
this.api('posts/create', {
text: this.refs.text.value == '' ? undefined : this.refs.text.value,
media_ids: files,
reply_to_id: this.reply ? this.reply.id : undefined,
reply_id: this.reply ? this.reply.id : undefined,
channel_id: this.channel.id
}).then(data => {
this.clear();

View File

@ -1,6 +1,6 @@
<mk-post-detail title={ title }>
<div class="main">
<button class="read-more" if={ p.reply_to && p.reply_to.reply_to_id && context == null } title="会話をもっと読み込む" onclick={ loadContext } disabled={ contextFetching }>
<button class="read-more" if={ p.reply && p.reply.reply_id && context == null } title="会話をもっと読み込む" onclick={ loadContext } disabled={ contextFetching }>
<i class="fa fa-ellipsis-v" if={ !contextFetching }></i>
<i class="fa fa-spinner fa-pulse" if={ contextFetching }></i>
</button>
@ -9,8 +9,8 @@
<mk-post-detail-sub post={ post }/>
</virtual>
</div>
<div class="reply-to" if={ p.reply_to }>
<mk-post-detail-sub post={ p.reply_to }/>
<div class="reply-to" if={ p.reply }>
<mk-post-detail-sub post={ p.reply }/>
</div>
<div class="repost" if={ isRepost }>
<p>
@ -329,7 +329,7 @@
// Fetch context
this.api('posts/context', {
post_id: this.p.reply_to_id
post_id: this.p.reply_id
}).then(context => {
this.update({
contextFetching: false,

View File

@ -475,7 +475,7 @@
this.api('posts/create', {
text: this.refs.text.value == '' ? undefined : this.refs.text.value,
media_ids: files,
reply_to_id: this.inReplyToPost ? this.inReplyToPost.id : undefined,
reply_id: this.inReplyToPost ? this.inReplyToPost.id : undefined,
repost_id: this.repost ? this.repost.id : undefined,
poll: this.poll ? this.refs.poll.get() : undefined
}).then(data => {

View File

@ -1,6 +1,6 @@
<mk-sub-post-content>
<div class="body">
<a class="reply" if={ post.reply_to_id }>
<a class="reply" if={ post.reply_id }>
<i class="fa fa-reply"></i>
</a>
<span ref="text"></span>

View File

@ -82,8 +82,8 @@
</mk-timeline>
<mk-timeline-post tabindex="-1" title={ title } onkeydown={ onKeyDown } dblclick={ onDblClick }>
<div class="reply-to" if={ p.reply_to }>
<mk-timeline-post-sub post={ p.reply_to }/>
<div class="reply-to" if={ p.reply }>
<mk-timeline-post-sub post={ p.reply }/>
</div>
<div class="repost" if={ isRepost }>
<p>
@ -113,7 +113,7 @@
<div class="body">
<div class="text" ref="text">
<p class="channel" if={ p.channel != null }><a href={ CONFIG.chUrl + '/' + p.channel.id } target="_blank">{ p.channel.title }</a>:</p>
<a class="reply" if={ p.reply_to }>
<a class="reply" if={ p.reply }>
<i class="fa fa-reply"></i>
</a>
<p class="dummy"></p>

View File

@ -1,5 +1,5 @@
<mk-post-detail>
<button class="read-more" if={ p.reply_to && p.reply_to.reply_to_id && context == null } onclick={ loadContext } disabled={ loadingContext }>
<button class="read-more" if={ p.reply && p.reply.reply_id && context == null } onclick={ loadContext } disabled={ loadingContext }>
<i class="fa fa-ellipsis-v" if={ !contextFetching }></i>
<i class="fa fa-spinner fa-pulse" if={ contextFetching }></i>
</button>
@ -8,8 +8,8 @@
<mk-post-detail-sub post={ post }/>
</virtual>
</div>
<div class="reply-to" if={ p.reply_to }>
<mk-post-detail-sub post={ p.reply_to }/>
<div class="reply-to" if={ p.reply }>
<mk-post-detail-sub post={ p.reply }/>
</div>
<div class="repost" if={ isRepost }>
<p>
@ -348,7 +348,7 @@
// Fetch context
this.api('posts/context', {
post_id: this.p.reply_to_id
post_id: this.p.reply_id
}).then(context => {
this.update({
contextFetching: false,

View File

@ -267,7 +267,7 @@
this.api('posts/create', {
text: this.refs.text.value == '' ? undefined : this.refs.text.value,
media_ids: files,
reply_to_id: opts.reply ? opts.reply.id : undefined,
reply_id: opts.reply ? opts.reply.id : undefined,
poll: this.poll ? this.refs.poll.get() : undefined
}).then(data => {
this.trigger('post');

View File

@ -1,5 +1,5 @@
<mk-sub-post-content>
<div class="body"><a class="reply" if={ post.reply_to_id }><i class="fa fa-reply"></i></a><span ref="text"></span><a class="quote" if={ post.repost_id } href={ '/post:' + post.repost_id }>RP: ...</a></div>
<div class="body"><a class="reply" if={ post.reply_id }><i class="fa fa-reply"></i></a><span ref="text"></span><a class="quote" if={ post.repost_id } href={ '/post:' + post.repost_id }>RP: ...</a></div>
<details if={ post.media }>
<summary>({ post.media.length }個のメディア)</summary>
<mk-images-viewer images={ post.media }/>

View File

@ -137,8 +137,8 @@
</mk-timeline>
<mk-timeline-post class={ repost: isRepost }>
<div class="reply-to" if={ p.reply_to }>
<mk-timeline-post-sub post={ p.reply_to }/>
<div class="reply-to" if={ p.reply }>
<mk-timeline-post-sub post={ p.reply }/>
</div>
<div class="repost" if={ isRepost }>
<p>
@ -165,7 +165,7 @@
<div class="body">
<div class="text" ref="text">
<p class="channel" if={ p.channel != null }><a href={ CONFIG.chUrl + '/' + p.channel.id } target="_blank">{ p.channel.title }</a>:</p>
<a class="reply" if={ p.reply_to }>
<a class="reply" if={ p.reply }>
<i class="fa fa-reply"></i>
</a>
<p class="dummy"></p>

View File

@ -277,15 +277,15 @@ describe('API', () => {
const me = await insertSakurako();
const post = {
text: 'さく',
reply_to_id: himaPost._id.toString()
reply_id: himaPost._id.toString()
};
const res = await request('/posts/create', post, me);
res.should.have.status(200);
res.body.should.be.a('object');
res.body.should.have.property('text').eql(post.text);
res.body.should.have.property('reply_to_id').eql(post.reply_to_id);
res.body.should.have.property('reply_to');
res.body.reply_to.should.have.property('text').eql(himaPost.text);
res.body.should.have.property('reply_id').eql(post.reply_id);
res.body.should.have.property('reply');
res.body.reply.should.have.property('text').eql(himaPost.text);
}));
it('repostできる', async(async () => {
@ -350,7 +350,7 @@ describe('API', () => {
const me = await insertSakurako();
const post = {
text: 'さく',
reply_to_id: '000000000000000000000000'
reply_id: '000000000000000000000000'
};
const res = await request('/posts/create', post, me);
res.should.have.status(400);
@ -369,7 +369,7 @@ describe('API', () => {
const me = await insertSakurako();
const post = {
text: 'さく',
reply_to_id: 'kyoppie'
reply_id: 'kyoppie'
};
const res = await request('/posts/create', post, me);
res.should.have.status(400);