diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml
index 3c4781f3f7..e291de07bd 100644
--- a/locales/ja-JP.yml
+++ b/locales/ja-JP.yml
@@ -788,6 +788,7 @@ desktop/views/components/renote-form.vue:
quote: "引用する..."
cancel: "キャンセル"
renote: "Renote"
+ renote-home: "Renote (ホーム)"
reposting: "しています..."
success: "Renoteしました!"
failure: "Renoteに失敗しました"
diff --git a/src/client/app/desktop/views/components/renote-form.vue b/src/client/app/desktop/views/components/renote-form.vue
index c538b90dac..e6a09c3eea 100644
--- a/src/client/app/desktop/views/components/renote-form.vue
+++ b/src/client/app/desktop/views/components/renote-form.vue
@@ -5,7 +5,8 @@
@@ -24,14 +25,16 @@ export default Vue.extend({
data() {
return {
wait: false,
- quote: false
+ quote: false,
+ visibility: this.$store.state.settings.defaultNoteVisibility
};
},
methods: {
- ok() {
+ ok(v: string) {
this.wait = true;
this.$root.api('notes/create', {
- renoteId: this.note.id
+ renoteId: this.note.id,
+ visibility: v || this.visibility
}).then(data => {
this.$emit('posted');
this.$notify(this.$t('success'));
@@ -81,7 +84,11 @@ export default Vue.extend({
height 40px
&.cancel
+ right 280px
+
+ &.home
right 148px
+ font-size 13px
&.ok
right 16px
diff --git a/src/remote/activitypub/kernel/announce/note.ts b/src/remote/activitypub/kernel/announce/note.ts
index 60f2b9baa0..19ea6306e3 100644
--- a/src/remote/activitypub/kernel/announce/note.ts
+++ b/src/remote/activitypub/kernel/announce/note.ts
@@ -35,17 +35,11 @@ export default async function(resolver: Resolver, actor: IRemoteUser, activity:
log(`Creating the (Re)Note: ${uri}`);
//#region Visibility
- let visibility = 'public';
+ const visibility = getVisibility(activity.to, activity.cc, actor);
+
let visibleUsers: IUser[] = [];
- if (!note.to.includes('https://www.w3.org/ns/activitystreams#Public')) {
- if (note.cc.includes('https://www.w3.org/ns/activitystreams#Public')) {
- visibility = 'home';
- } else if (note.to.includes(`${actor.uri}/followers`)) { // TODO: person.followerと照合するべき?
- visibility = 'followers';
- } else {
- visibility = 'specified';
- visibleUsers = await Promise.all(note.to.map(uri => resolvePerson(uri)));
- }
+ if (visibility == 'specified') {
+ visibleUsers = await Promise.all(note.to.map(uri => resolvePerson(uri)));
}
//#endergion
@@ -57,3 +51,22 @@ export default async function(resolver: Resolver, actor: IRemoteUser, activity:
uri
});
}
+
+type visibility = 'public' | 'home' | 'followers' | 'specified' | 'private';
+
+function getVisibility(to: string[], cc: string[], actor: IRemoteUser): visibility {
+ const PUBLIC = 'https://www.w3.org/ns/activitystreams#Public';
+
+ to = to || [];
+ cc = cc || [];
+
+ if (to.includes(PUBLIC)) {
+ return 'public';
+ } else if (cc.includes(PUBLIC)) {
+ return 'home';
+ } else if (to.includes(`${actor.uri}/followers`)) {
+ return 'followers';
+ } else {
+ return 'specified';
+ }
+}
diff --git a/src/remote/activitypub/renderer/announce.ts b/src/remote/activitypub/renderer/announce.ts
index 18e23cc336..f6f2f9bdcd 100644
--- a/src/remote/activitypub/renderer/announce.ts
+++ b/src/remote/activitypub/renderer/announce.ts
@@ -4,13 +4,26 @@ import { INote } from '../../../models/note';
export default (object: any, note: INote) => {
const attributedTo = `${config.url}/users/${note.userId}`;
+ let to: string[] = [];
+ let cc: string[] = [];
+
+ if (note.visibility == 'public') {
+ to = ['https://www.w3.org/ns/activitystreams#Public'];
+ cc = [`${attributedTo}/followers`];
+ } else if (note.visibility == 'home') {
+ to = [`${attributedTo}/followers`];
+ cc = ['https://www.w3.org/ns/activitystreams#Public'];
+ } else {
+ return null;
+ }
+
return {
id: `${config.url}/notes/${note._id}/activity`,
actor: `${config.url}/users/${note.userId}`,
type: 'Announce',
published: note.createdAt.toISOString(),
- to: ['https://www.w3.org/ns/activitystreams#Public'],
- cc: [attributedTo, `${attributedTo}/followers`],
+ to,
+ cc,
object
};
};
diff --git a/src/remote/activitypub/renderer/index.ts b/src/remote/activitypub/renderer/index.ts
index 55b2801cad..30f5f1cff5 100644
--- a/src/remote/activitypub/renderer/index.ts
+++ b/src/remote/activitypub/renderer/index.ts
@@ -2,6 +2,8 @@ import config from '../../../config';
import * as uuid from 'uuid';
export default (x: any) => {
+ if (x == null) return null;
+
if (x !== null && typeof x === 'object' && x.id == null) {
x.id = `${config.url}/${uuid.v4()}`;
}