mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-30 20:33:02 +00:00
wip
This commit is contained in:
parent
924119651a
commit
484d17f53f
14 changed files with 73 additions and 50 deletions
|
@ -1,13 +1,16 @@
|
||||||
<template>
|
<template>
|
||||||
<button class="mk-follow-button"
|
<button class="mk-follow-button"
|
||||||
:class="{ wait: wait, follow: !user.isFollowing, unfollow: user.isFollowing }"
|
:class="{ wait: wait, following: user.isFollowing, unfollow: user.isFollowing }"
|
||||||
@click="onClick"
|
@click="onClick"
|
||||||
:disabled="wait"
|
:disabled="wait"
|
||||||
>
|
>
|
||||||
<template v-if="!wait && user.isFollowing">%fa:minus%</template>
|
<template v-if="!wait">
|
||||||
<template v-if="!wait && !user.isFollowing">%fa:plus%</template>
|
<template v-if="user.hasPendingFollowRequestFromYou">%fa:hourglass-half% %i18n:@request-pending%</template>
|
||||||
<template v-if="wait">%fa:spinner .pulse .fw%</template>
|
<template v-else-if="user.isFollowing">%fa:minus% %i18n:@unfollow%</template>
|
||||||
{{ user.isFollowing ? '%i18n:@unfollow%' : '%i18n:@follow%' }}
|
<template v-else-if="!user.isFollowing && user.isLocked">%fa:plus% %i18n:@follow-request%</template>
|
||||||
|
<template v-else-if="!user.isFollowing && !user.isLocked">%fa:plus% %i18n:@follow%</template>
|
||||||
|
</template>
|
||||||
|
<template v-else>%fa:spinner .pulse .fw%</template>
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -65,6 +68,17 @@ export default Vue.extend({
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.wait = false;
|
this.wait = false;
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
if (this.user.isLocked && this.user.hasPendingFollowRequestFromYou) {
|
||||||
|
(this as any).api('following/requests/cancel', {
|
||||||
|
userId: this.user.id
|
||||||
|
}).then(() => {
|
||||||
|
this.user.hasPendingFollowRequestFromYou = false;
|
||||||
|
}).catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
}).then(() => {
|
||||||
|
this.wait = false;
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
(this as any).api('following/create', {
|
(this as any).api('following/create', {
|
||||||
userId: this.user.id
|
userId: this.user.id
|
||||||
|
@ -78,6 +92,7 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -90,11 +105,11 @@ export default Vue.extend({
|
||||||
cursor pointer
|
cursor pointer
|
||||||
padding 0 16px
|
padding 0 16px
|
||||||
margin 0
|
margin 0
|
||||||
height inherit
|
line-height 36px
|
||||||
font-size 16px
|
font-size 14px
|
||||||
outline none
|
outline none
|
||||||
border solid 1px $theme-color
|
border solid 1px $theme-color
|
||||||
border-radius 4px
|
border-radius 36px
|
||||||
|
|
||||||
*
|
*
|
||||||
pointer-events none
|
pointer-events none
|
||||||
|
|
|
@ -184,7 +184,6 @@ root(isDark)
|
||||||
|
|
||||||
> .mk-follow-button
|
> .mk-follow-button
|
||||||
float right
|
float right
|
||||||
height 40px
|
|
||||||
|
|
||||||
> .title
|
> .title
|
||||||
margin 8px 0
|
margin 8px 0
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import * as mongo from 'mongodb';
|
import * as mongo from 'mongodb';
|
||||||
import User, { IRemoteUser } from '../../../../models/user';
|
import User, { IRemoteUser } from '../../../../models/user';
|
||||||
import config from '../../../../config';
|
import config from '../../../../config';
|
||||||
import accept from '../../../../services/user/accept-follow-request';
|
import accept from '../../../../services/following/requests/accept';
|
||||||
import { IFollow } from '../../type';
|
import { IFollow } from '../../type';
|
||||||
|
|
||||||
export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
||||||
|
|
|
@ -23,5 +23,5 @@ export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
||||||
throw new Error('フォローしようとしているユーザーはローカルユーザーではありません');
|
throw new Error('フォローしようとしているユーザーはローカルユーザーではありません');
|
||||||
}
|
}
|
||||||
|
|
||||||
await follow(actor, followee, activity);
|
await follow(actor, followee);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import * as mongo from 'mongodb';
|
import * as mongo from 'mongodb';
|
||||||
import User, { IRemoteUser } from '../../../../models/user';
|
import User, { IRemoteUser } from '../../../../models/user';
|
||||||
import config from '../../../../config';
|
import config from '../../../../config';
|
||||||
import reject from '../../../../services/user/reject-follow-request';
|
import reject from '../../../../services/following/requests/reject';
|
||||||
import { IFollow } from '../../type';
|
import { IFollow } from '../../type';
|
||||||
|
|
||||||
export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
||||||
|
|
|
@ -23,5 +23,5 @@ export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
||||||
throw new Error('フォロー解除しようとしているユーザーはローカルユーザーではありません');
|
throw new Error('フォロー解除しようとしているユーザーはローカルユーザーではありません');
|
||||||
}
|
}
|
||||||
|
|
||||||
await unfollow(actor, followee, activity);
|
await unfollow(actor, followee);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,7 @@ const httpSignature = require('http-signature');
|
||||||
import { createHttp } from '../queue';
|
import { createHttp } from '../queue';
|
||||||
import pack from '../remote/activitypub/renderer';
|
import pack from '../remote/activitypub/renderer';
|
||||||
import Note from '../models/note';
|
import Note from '../models/note';
|
||||||
import User, { isLocalUser } from '../models/user';
|
import User, { isLocalUser, ILocalUser } from '../models/user';
|
||||||
import renderNote from '../remote/activitypub/renderer/note';
|
import renderNote from '../remote/activitypub/renderer/note';
|
||||||
import renderKey from '../remote/activitypub/renderer/key';
|
import renderKey from '../remote/activitypub/renderer/key';
|
||||||
import renderPerson from '../remote/activitypub/renderer/person';
|
import renderPerson from '../remote/activitypub/renderer/person';
|
||||||
|
@ -69,7 +69,10 @@ router.get('/notes/:note', async (ctx, next) => {
|
||||||
router.get('/users/:user/outbox', async ctx => {
|
router.get('/users/:user/outbox', async ctx => {
|
||||||
const userId = new mongo.ObjectID(ctx.params.user);
|
const userId = new mongo.ObjectID(ctx.params.user);
|
||||||
|
|
||||||
const user = await User.findOne({ _id: userId });
|
const user = await User.findOne({
|
||||||
|
_id: userId,
|
||||||
|
host: null
|
||||||
|
});
|
||||||
|
|
||||||
if (user === null) {
|
if (user === null) {
|
||||||
ctx.status = 404;
|
ctx.status = 404;
|
||||||
|
@ -91,7 +94,10 @@ router.get('/users/:user/outbox', async ctx => {
|
||||||
router.get('/users/:user/publickey', async ctx => {
|
router.get('/users/:user/publickey', async ctx => {
|
||||||
const userId = new mongo.ObjectID(ctx.params.user);
|
const userId = new mongo.ObjectID(ctx.params.user);
|
||||||
|
|
||||||
const user = await User.findOne({ _id: userId });
|
const user = await User.findOne({
|
||||||
|
_id: userId,
|
||||||
|
host: null
|
||||||
|
});
|
||||||
|
|
||||||
if (user === null) {
|
if (user === null) {
|
||||||
ctx.status = 404;
|
ctx.status = 404;
|
||||||
|
@ -109,14 +115,17 @@ router.get('/users/:user/publickey', async ctx => {
|
||||||
router.get('/users/:user', async ctx => {
|
router.get('/users/:user', async ctx => {
|
||||||
const userId = new mongo.ObjectID(ctx.params.user);
|
const userId = new mongo.ObjectID(ctx.params.user);
|
||||||
|
|
||||||
const user = await User.findOne({ _id: userId });
|
const user = await User.findOne({
|
||||||
|
_id: userId,
|
||||||
|
host: null
|
||||||
|
});
|
||||||
|
|
||||||
if (user === null) {
|
if (user === null) {
|
||||||
ctx.status = 404;
|
ctx.status = 404;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.body = pack(renderPerson(user));
|
ctx.body = pack(renderPerson(user as ILocalUser));
|
||||||
});
|
});
|
||||||
|
|
||||||
// follow form
|
// follow form
|
||||||
|
|
|
@ -449,12 +449,12 @@ const endpoints: Endpoint[] = [
|
||||||
kind: 'following-write'
|
kind: 'following-write'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'following/request/accept',
|
name: 'following/requests/accept',
|
||||||
withCredential: true,
|
withCredential: true,
|
||||||
kind: 'following-write'
|
kind: 'following-write'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'following/request/reject',
|
name: 'following/requests/reject',
|
||||||
withCredential: true,
|
withCredential: true,
|
||||||
kind: 'following-write'
|
kind: 'following-write'
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import $ from 'cafy'; import ID from '../../../../../cafy-id';
|
import $ from 'cafy'; import ID from '../../../../../cafy-id';
|
||||||
import acceptFollowRequest from '../../../../../services/user/accept-follow-request';
|
import acceptFollowRequest from '../../../../../services/following/requests/accept';
|
||||||
import User from '../../../../../models/user';
|
import User from '../../../../../models/user';
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -1,5 +1,5 @@
|
||||||
import $ from 'cafy'; import ID from '../../../../../cafy-id';
|
import $ from 'cafy'; import ID from '../../../../../cafy-id';
|
||||||
import rejectFollowRequest from '../../../../../services/user/reject-follow-request';
|
import rejectFollowRequest from '../../../../../services/following/requests/reject';
|
||||||
import User from '../../../../../models/user';
|
import User from '../../../../../models/user';
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -5,7 +5,7 @@ import $ from 'cafy'; import ID from '../../../../cafy-id';
|
||||||
import User, { isValidName, isValidDescription, isValidLocation, isValidBirthday, pack } from '../../../../models/user';
|
import User, { isValidName, isValidDescription, isValidLocation, isValidBirthday, pack } from '../../../../models/user';
|
||||||
import event from '../../../../publishers/stream';
|
import event from '../../../../publishers/stream';
|
||||||
import DriveFile from '../../../../models/drive-file';
|
import DriveFile from '../../../../models/drive-file';
|
||||||
import acceptAllFollowRequests from '../../../../services/user/accept-all-follow-requests';
|
import acceptAllFollowRequests from '../../../../services/following/requests/accept-all';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update myself
|
* Update myself
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import User, { IUser } from "../../models/user";
|
import User, { IUser } from "../../../models/user";
|
||||||
import FollowRequest from "../../models/follow-request";
|
import FollowRequest from "../../../models/follow-request";
|
||||||
import accept from './accept-follow-request';
|
import accept from './accept';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 指定したユーザー宛てのフォローリクエストをすべて承認
|
* 指定したユーザー宛てのフォローリクエストをすべて承認
|
|
@ -1,12 +1,12 @@
|
||||||
import User, { IUser, isRemoteUser, ILocalUser } from "../../models/user";
|
import User, { IUser, isRemoteUser, ILocalUser } from "../../../models/user";
|
||||||
import FollowRequest from "../../models/follow-request";
|
import FollowRequest from "../../../models/follow-request";
|
||||||
import pack from '../../remote/activitypub/renderer';
|
import pack from '../../../remote/activitypub/renderer';
|
||||||
import renderFollow from '../../remote/activitypub/renderer/follow';
|
import renderFollow from '../../../remote/activitypub/renderer/follow';
|
||||||
import renderAccept from '../../remote/activitypub/renderer/accept';
|
import renderAccept from '../../../remote/activitypub/renderer/accept';
|
||||||
import { deliver } from '../../queue';
|
import { deliver } from '../../../queue';
|
||||||
import Following from "../../models/following";
|
import Following from "../../../models/following";
|
||||||
import FollowingLog from "../../models/following-log";
|
import FollowingLog from "../../../models/following-log";
|
||||||
import FollowedLog from "../../models/followed-log";
|
import FollowedLog from "../../../models/followed-log";
|
||||||
|
|
||||||
export default async function(followee: IUser, follower: IUser) {
|
export default async function(followee: IUser, follower: IUser) {
|
||||||
const following = await Following.insert({
|
const following = await Following.insert({
|
|
@ -1,9 +1,9 @@
|
||||||
import User, { IUser, isRemoteUser, ILocalUser } from "../../models/user";
|
import User, { IUser, isRemoteUser, ILocalUser } from "../../../models/user";
|
||||||
import FollowRequest from "../../models/follow-request";
|
import FollowRequest from "../../../models/follow-request";
|
||||||
import pack from '../../remote/activitypub/renderer';
|
import pack from '../../../remote/activitypub/renderer';
|
||||||
import renderFollow from '../../remote/activitypub/renderer/follow';
|
import renderFollow from '../../../remote/activitypub/renderer/follow';
|
||||||
import renderReject from '../../remote/activitypub/renderer/reject';
|
import renderReject from '../../../remote/activitypub/renderer/reject';
|
||||||
import { deliver } from '../../queue';
|
import { deliver } from '../../../queue';
|
||||||
|
|
||||||
export default async function(followee: IUser, follower: IUser) {
|
export default async function(followee: IUser, follower: IUser) {
|
||||||
if (isRemoteUser(follower)) {
|
if (isRemoteUser(follower)) {
|
Loading…
Reference in a new issue