mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-11-26 16:03:02 +00:00
wip
This commit is contained in:
parent
346c2959e0
commit
71c3e11708
7 changed files with 65 additions and 7 deletions
|
@ -21,7 +21,8 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
|
||||||
const channel = await Channel.insert({
|
const channel = await Channel.insert({
|
||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
user_id: user._id,
|
user_id: user._id,
|
||||||
title: title
|
title: title,
|
||||||
|
index: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
// Response
|
// Response
|
||||||
|
|
|
@ -153,6 +153,16 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => {
|
||||||
if (repost && !isQuote) {
|
if (repost && !isQuote) {
|
||||||
return rej('チャンネル内部では引用ではないRepostをすることはできません');
|
return rej('チャンネル内部では引用ではないRepostをすることはできません');
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// 返信対象の投稿がチャンネルへの投稿だったらダメ
|
||||||
|
if (inReplyToPost && inReplyToPost.channel_id != null) {
|
||||||
|
return rej('チャンネル外部からチャンネル内部の投稿に返信することはできません');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Repost対象の投稿がチャンネルへの投稿だったらダメ
|
||||||
|
if (repost && repost.channel_id != null) {
|
||||||
|
return rej('チャンネル外部からチャンネル内部の投稿をRepostすることはできません');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get 'poll' parameter
|
// Get 'poll' parameter
|
||||||
|
@ -199,6 +209,7 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => {
|
||||||
const post = await Post.insert({
|
const post = await Post.insert({
|
||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
channel_id: channel ? channel._id : undefined,
|
channel_id: channel ? channel._id : 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_to_id: inReplyToPost ? inReplyToPost._id : undefined,
|
||||||
repost_id: repost ? repost._id : undefined,
|
repost_id: repost ? repost._id : undefined,
|
||||||
|
@ -217,6 +228,12 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => {
|
||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
// Post processes
|
// Post processes
|
||||||
|
|
||||||
|
Channel.update({ _id: channel._id }, {
|
||||||
|
$inc: {
|
||||||
|
index: 1
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
User.update({ _id: user._id }, {
|
User.update({ _id: user._id }, {
|
||||||
$set: {
|
$set: {
|
||||||
latest_post: post
|
latest_post: post
|
||||||
|
|
|
@ -10,4 +10,5 @@ export type IChannel = {
|
||||||
created_at: Date;
|
created_at: Date;
|
||||||
title: string;
|
title: string;
|
||||||
user_id: mongo.ObjectID;
|
user_id: mongo.ObjectID;
|
||||||
|
index: number;
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,6 +8,7 @@ import Reaction from '../models/post-reaction';
|
||||||
import { IUser } from '../models/user';
|
import { IUser } from '../models/user';
|
||||||
import Vote from '../models/poll-vote';
|
import Vote from '../models/poll-vote';
|
||||||
import serializeApp from './app';
|
import serializeApp from './app';
|
||||||
|
import serializeChannel from './channel';
|
||||||
import serializeUser from './user';
|
import serializeUser from './user';
|
||||||
import serializeDriveFile from './drive-file';
|
import serializeDriveFile from './drive-file';
|
||||||
import parse from '../common/text';
|
import parse from '../common/text';
|
||||||
|
@ -76,8 +77,13 @@ const self = (
|
||||||
_post.app = await serializeApp(_post.app_id);
|
_post.app = await serializeApp(_post.app_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Populate channel
|
||||||
|
if (_post.channel_id) {
|
||||||
|
_post.channel = await serializeChannel(_post.channel_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Populate media
|
||||||
if (_post.media_ids) {
|
if (_post.media_ids) {
|
||||||
// Populate media
|
|
||||||
_post.media = await Promise.all(_post.media_ids.map(async fileId =>
|
_post.media = await Promise.all(_post.media_ids.map(async fileId =>
|
||||||
await serializeDriveFile(fileId)
|
await serializeDriveFile(fileId)
|
||||||
));
|
));
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
<mk-ui ref="ui">
|
<mk-ui ref="ui">
|
||||||
<main if={ !parent.fetching }>
|
<main if={ !parent.fetching }>
|
||||||
<h1>{ parent.channel.title }</h1>
|
<h1>{ parent.channel.title }</h1>
|
||||||
<mk-channel-post each={ parent.posts } post={ this }/>
|
<mk-channel-post if={ parent.posts } each={ parent.posts.reverse() } post={ this } form={ parent.refs.form }/>
|
||||||
<mk-channel-form channel={ parent.channel }/>
|
<hr>
|
||||||
|
<mk-channel-form channel={ parent.channel } ref="form"/>
|
||||||
</main>
|
</main>
|
||||||
</mk-ui>
|
</mk-ui>
|
||||||
<style>
|
<style>
|
||||||
|
@ -11,6 +12,8 @@
|
||||||
display block
|
display block
|
||||||
|
|
||||||
main
|
main
|
||||||
|
padding 8px
|
||||||
|
|
||||||
> h1
|
> h1
|
||||||
color #f00
|
color #f00
|
||||||
</style>
|
</style>
|
||||||
|
@ -57,9 +60,13 @@
|
||||||
|
|
||||||
<mk-channel-post>
|
<mk-channel-post>
|
||||||
<header>
|
<header>
|
||||||
<b>{ post.user.name }</b>
|
<a class="index" onclick={ reply }>{ post.index }:</a>
|
||||||
|
<a class="name" href={ '/' + post.user.username }><b>{ post.user.name }</b></a>
|
||||||
|
<mk-time time={ post.created_at } mode="detail"/>
|
||||||
|
<span>ID:<i>{ post.user.username }</i></span>
|
||||||
</header>
|
</header>
|
||||||
<div>
|
<div>
|
||||||
|
<a if={ post.reply_to }>>>{ post.reply_to.index }</a>
|
||||||
{ post.text }
|
{ post.text }
|
||||||
</div>
|
</div>
|
||||||
<style>
|
<style>
|
||||||
|
@ -69,17 +76,35 @@
|
||||||
padding 0
|
padding 0
|
||||||
|
|
||||||
> header
|
> header
|
||||||
> b
|
> .index
|
||||||
|
margin-right 0.25em
|
||||||
|
color #000
|
||||||
|
|
||||||
|
> .name
|
||||||
|
margin-right 0.5em
|
||||||
color #008000
|
color #008000
|
||||||
|
|
||||||
|
> mk-time
|
||||||
|
margin-right 0.5em
|
||||||
|
|
||||||
|
> div
|
||||||
|
padding 0 0 1em 2em
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
this.post = this.opts.post;
|
this.post = this.opts.post;
|
||||||
|
this.form = this.opts.form;
|
||||||
|
|
||||||
|
this.reply = () => {
|
||||||
|
this.form.update({
|
||||||
|
reply: this.post
|
||||||
|
});
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
</mk-channel-post>
|
</mk-channel-post>
|
||||||
|
|
||||||
<mk-channel-form>
|
<mk-channel-form>
|
||||||
<p if={ reply }>{ reply.user.name }への返信: (or <a onclick={ clearReply }>キャンセル</a>)</p>
|
<p if={ reply }><b>>>{ reply.index }</b> ({ reply.user.name }): <a onclick={ clearReply }>[x]</a></p>
|
||||||
<textarea ref="text" disabled={ wait }></textarea>
|
<textarea ref="text" disabled={ wait }></textarea>
|
||||||
<button class={ wait: wait } ref="submit" disabled={ wait || (refs.text.value.length == 0) } onclick={ post }>
|
<button class={ wait: wait } ref="submit" disabled={ wait || (refs.text.value.length == 0) } onclick={ post }>
|
||||||
{ wait ? 'やってます' : 'やる' }<mk-ellipsis if={ wait }/>
|
{ wait ? 'やってます' : 'やる' }<mk-ellipsis if={ wait }/>
|
||||||
|
|
|
@ -112,6 +112,7 @@
|
||||||
</header>
|
</header>
|
||||||
<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={ '/channel/' + p.channel.id }>{ p.channel.title }</a>:</p>
|
||||||
<a class="reply" if={ p.reply_to }>
|
<a class="reply" if={ p.reply_to }>
|
||||||
<i class="fa fa-reply"></i>
|
<i class="fa fa-reply"></i>
|
||||||
</a>
|
</a>
|
||||||
|
@ -333,6 +334,9 @@
|
||||||
font-weight 400
|
font-weight 400
|
||||||
font-style normal
|
font-style normal
|
||||||
|
|
||||||
|
> .channel
|
||||||
|
margin 0
|
||||||
|
|
||||||
> .reply
|
> .reply
|
||||||
margin-right 8px
|
margin-right 8px
|
||||||
color #717171
|
color #717171
|
||||||
|
|
|
@ -164,6 +164,7 @@
|
||||||
</header>
|
</header>
|
||||||
<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={ '/channel/' + p.channel.id }>{ p.channel.title }</a>:</p>
|
||||||
<a class="reply" if={ p.reply_to }>
|
<a class="reply" if={ p.reply_to }>
|
||||||
<i class="fa fa-reply"></i>
|
<i class="fa fa-reply"></i>
|
||||||
</a>
|
</a>
|
||||||
|
@ -373,6 +374,9 @@
|
||||||
mk-url-preview
|
mk-url-preview
|
||||||
margin-top 8px
|
margin-top 8px
|
||||||
|
|
||||||
|
> .channel
|
||||||
|
margin 0
|
||||||
|
|
||||||
> .reply
|
> .reply
|
||||||
margin-right 8px
|
margin-right 8px
|
||||||
color #717171
|
color #717171
|
||||||
|
|
Loading…
Reference in a new issue