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

View File

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

View File

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

View File

@ -62,7 +62,7 @@ module.exports = (params) => new Promise(async (res, rej) => {
} }
if (reply != undefined) { 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) { if (repost != undefined) {

View File

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

View File

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

View File

@ -48,7 +48,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
} as any; } as any;
if (reply != undefined) { 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) { if (repost != undefined) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
<mk-post-detail title={ title }> <mk-post-detail title={ title }>
<div class="main"> <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-ellipsis-v" if={ !contextFetching }></i>
<i class="fa fa-spinner fa-pulse" if={ contextFetching }></i> <i class="fa fa-spinner fa-pulse" if={ contextFetching }></i>
</button> </button>
@ -9,8 +9,8 @@
<mk-post-detail-sub post={ post }/> <mk-post-detail-sub post={ post }/>
</virtual> </virtual>
</div> </div>
<div class="reply-to" if={ p.reply_to }> <div class="reply-to" if={ p.reply }>
<mk-post-detail-sub post={ p.reply_to }/> <mk-post-detail-sub post={ p.reply }/>
</div> </div>
<div class="repost" if={ isRepost }> <div class="repost" if={ isRepost }>
<p> <p>
@ -329,7 +329,7 @@
// Fetch context // Fetch context
this.api('posts/context', { this.api('posts/context', {
post_id: this.p.reply_to_id post_id: this.p.reply_id
}).then(context => { }).then(context => {
this.update({ this.update({
contextFetching: false, contextFetching: false,

View File

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

View File

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

View File

@ -82,8 +82,8 @@
</mk-timeline> </mk-timeline>
<mk-timeline-post tabindex="-1" title={ title } onkeydown={ onKeyDown } dblclick={ onDblClick }> <mk-timeline-post tabindex="-1" title={ title } onkeydown={ onKeyDown } dblclick={ onDblClick }>
<div class="reply-to" if={ p.reply_to }> <div class="reply-to" if={ p.reply }>
<mk-timeline-post-sub post={ p.reply_to }/> <mk-timeline-post-sub post={ p.reply }/>
</div> </div>
<div class="repost" if={ isRepost }> <div class="repost" if={ isRepost }>
<p> <p>
@ -113,7 +113,7 @@
<div class="body"> <div class="body">
<div class="text" ref="text"> <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> <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> <i class="fa fa-reply"></i>
</a> </a>
<p class="dummy"></p> <p class="dummy"></p>

View File

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

View File

@ -267,7 +267,7 @@
this.api('posts/create', { this.api('posts/create', {
text: this.refs.text.value == '' ? undefined : this.refs.text.value, text: this.refs.text.value == '' ? undefined : this.refs.text.value,
media_ids: files, 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 poll: this.poll ? this.refs.poll.get() : undefined
}).then(data => { }).then(data => {
this.trigger('post'); this.trigger('post');

View File

@ -1,5 +1,5 @@
<mk-sub-post-content> <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 }> <details if={ post.media }>
<summary>({ post.media.length }個のメディア)</summary> <summary>({ post.media.length }個のメディア)</summary>
<mk-images-viewer images={ post.media }/> <mk-images-viewer images={ post.media }/>

View File

@ -137,8 +137,8 @@
</mk-timeline> </mk-timeline>
<mk-timeline-post class={ repost: isRepost }> <mk-timeline-post class={ repost: isRepost }>
<div class="reply-to" if={ p.reply_to }> <div class="reply-to" if={ p.reply }>
<mk-timeline-post-sub post={ p.reply_to }/> <mk-timeline-post-sub post={ p.reply }/>
</div> </div>
<div class="repost" if={ isRepost }> <div class="repost" if={ isRepost }>
<p> <p>
@ -165,7 +165,7 @@
<div class="body"> <div class="body">
<div class="text" ref="text"> <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> <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> <i class="fa fa-reply"></i>
</a> </a>
<p class="dummy"></p> <p class="dummy"></p>

View File

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