Skip to content

Commit

Permalink
Merge branch 'feat-update-visibility' into yuriha-master
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriha-chan committed Feb 22, 2024
2 parents cd83de3 + f6dec64 commit b8fe963
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 22 deletions.
8 changes: 8 additions & 0 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ copyLinkRenote: "Copy renote link"
delete: "Delete"
deleteAndEdit: "Delete and edit"
deleteAndEditConfirm: "Are you sure you want to redraft this note? This means you will lose all reactions, renotes, and replies to it."
limitToHome: "Make this note only visibile in home timelines"
limitToHomeConfirm: "Are you sure you want to change the visibility of this note to home? This action can't be reverted."
limitToFollowers: "Make this note only visible to your followers"
limitToFollowersConfirm: "Are you sure you want to change the visibility of this note to followers? This action can't be reverted."
limitToLocalOnly: "Make this note only visible within this server"
limitToLocalOnlyConfirm: "Are you sure you want to change the visibility of this note to local-only? Deletion requests will be sent to federated servers and this action can't be reverted."
limitToLikeOnly: "Receive only like reactions on this note"
limitToLikeOnlyConfirm: "Are you sure you want to change reaction acceptance to likes only? This action can't be reverted."
addToList: "Add to list"
addToAntenna: "Add to antenna"
sendMessage: "Send a message"
Expand Down
6 changes: 3 additions & 3 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ deleteAndEdit: "削除して編集"
deleteAndEditConfirm: "このノートを削除してもう一度編集しますか?このノートへのリアクション、リノート、返信も全て削除されます。"
limitToHome: "公開範囲をホームに制限"
limitToHomeConfirm: "このノートの公開範囲を「ホーム」に変更しますか?この操作は取り消せません。"
limitToFollowers: "公開範囲をホームに制限"
limitToFollowers: "公開範囲を「フォロワー」に制限"
limitToFollowersConfirm: "このノートの公開範囲を「フォロワー」に変更しますか?この操作は取り消せません。"
limitToLocalOnly: "公開範囲を「ローカルのみ」に制限"
limitToLocalOnlyConfirm: "このノートの公開範囲を「ローカルのみ」に変更しますか?連合先サーバーへはノートが削除されたと通知します。この操作は取り消せません。"
limitToLikeOnly: "公開範囲を「ローカルのみ」に制限"
limitToLikeOnlyConfirm: "このノートが受け付けるリアクションをハートのみに制限しますか?この操作は取り消せません。"
limitToLikeOnly: "リアクションの受け入れを「いいね」のみに制限"
limitToLikeOnlyConfirm: "このノートが受け付けるリアクションを「いいね」のみに制限しますか?この操作は取り消せません。"
addToList: "リストに追加"
addToAntenna: "アンテナに追加"
sendMessage: "メッセージを送信"
Expand Down
8 changes: 8 additions & 0 deletions locales/ja-KS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ copyLinkRenote: "リノートのリンクをコピーするで?"
delete: "ほかす"
deleteAndEdit: "ほかして直す"
deleteAndEditConfirm: "このノートをほかしてもっかい直す?このノートへのツッコミ、リノート、返信も全部消えるんやけどそれでもええん?"
limitToHome: "やっぱホームにしとく"
limitToHomeConfirm: "このノートの公開範囲を「ホーム」に変えたいんか?たんまはなしやで。"
limitToFollowers: "やっぱフォロワーだけにしとく"
limitToFollowersConfirm: "このノートの公開範囲を「フォロワー」に変えたいんか?たんまはなしやで。"
limitToLocalOnly: "やっぱローカルだけにしとく"
limitToLocalOnlyConfirm: "このノートの公開範囲を「ローカルのみ」に変えたいんか?連合先には消したことにしとくからな。たんまはなしやで。"
limitToLikeOnly: "やっぱいいねしか要らんことにする"
limitToLikeOnlyConfirm: "このノートへのつっこみを「いいね」だけに変えたいんか?たんまはなしやで。"
addToList: "リストに入れたる"
addToAntenna: "アンテナに入れる"
sendMessage: "メッセージを送る"
Expand Down
6 changes: 6 additions & 0 deletions packages/backend/src/core/CoreModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { MfmService } from './MfmService.js';
import { ModerationLogService } from './ModerationLogService.js';
import { NoteCreateService } from './NoteCreateService.js';
import { NoteDeleteService } from './NoteDeleteService.js';
import { NoteUpdateVisibilityService } from './NoteUpdateVisibilityService.js';
import { NotePiningService } from './NotePiningService.js';
import { NoteReadService } from './NoteReadService.js';
import { NotificationService } from './NotificationService.js';
Expand Down Expand Up @@ -171,6 +172,7 @@ const $MfmService: Provider = { provide: 'MfmService', useExisting: MfmService }
const $ModerationLogService: Provider = { provide: 'ModerationLogService', useExisting: ModerationLogService };
const $NoteCreateService: Provider = { provide: 'NoteCreateService', useExisting: NoteCreateService };
const $NoteDeleteService: Provider = { provide: 'NoteDeleteService', useExisting: NoteDeleteService };
const $NoteUpdateVisibilityService: Provider = { provide: 'NoteUpdateVisibilityService', useExisting: NoteUpdateVisibilityService };
const $NotePiningService: Provider = { provide: 'NotePiningService', useExisting: NotePiningService };
const $NoteReadService: Provider = { provide: 'NoteReadService', useExisting: NoteReadService };
const $NotificationService: Provider = { provide: 'NotificationService', useExisting: NotificationService };
Expand Down Expand Up @@ -310,6 +312,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
ModerationLogService,
NoteCreateService,
NoteDeleteService,
NoteUpdateVisibilityService,
NotePiningService,
NoteReadService,
NotificationService,
Expand Down Expand Up @@ -445,6 +448,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
$ModerationLogService,
$NoteCreateService,
$NoteDeleteService,
$NoteUpdateVisibilityService,
$NotePiningService,
$NoteReadService,
$NotificationService,
Expand Down Expand Up @@ -581,6 +585,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
ModerationLogService,
NoteCreateService,
NoteDeleteService,
NoteUpdateVisibilityService,
NotePiningService,
NoteReadService,
NotificationService,
Expand Down Expand Up @@ -715,6 +720,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
$ModerationLogService,
$NoteCreateService,
$NoteDeleteService,
$NoteUpdateVisibilityService,
$NotePiningService,
$NoteReadService,
$NotificationService,
Expand Down
3 changes: 3 additions & 0 deletions packages/backend/src/core/GlobalEventService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ export interface NoteEventTypes {
deleted: {
deletedAt: Date;
};
visibilityUpdated: {
updatedAt: Date;
};
updated: {
cw: string | null;
text: string;
Expand Down
18 changes: 10 additions & 8 deletions packages/backend/src/core/NoteUpdateVisibilityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ export class NoteUpdateVisibilityService {
async updateVisibility(user: { id: MiUser['id']; uri: MiUser['uri']; host: MiUser['host']; isBot: MiUser['isBot']; }, note: MiNote, visibility?: string, localOnly?: boolean, reactionAcceptance?: MiNote['reactionAcceptance'], quiet = false, updater?: MiUser) {
if (note.visibility === 'home' && visibility === 'public') {
throw new Error('cannot change home visibility to public');
} else if (note.visibility === 'followers' && !visibility === 'specified') {
} else if (note.visibility === 'followers' && (visibility === 'home' || visibility === 'public')) {
throw new Error('cannot change followers visibility to home or public');
} else if (note.visibility === 'specified') {
} else if (note.visibility === 'specified' && visibility) {
throw new Error('cannot change specified visibility');
}

Expand Down Expand Up @@ -88,11 +88,13 @@ export class NoteUpdateVisibilityService {
this.searchService.unindexNote(note);
}

await this.notesRepository.update(note.id, {
visibility?,
localOnly?,
reactionAcceptance?
});
const to = {
visibility: visibility ?? undefined,
localOnly: localOnly ?? undefined,
reactionAcceptance: reactionAcceptance ?? undefined,
};

await this.notesRepository.update(note.id, to);

if (updater && (note.userId !== updater.id)) {
const user = await this.usersRepository.findOneByOrFail({ id: note.userId });
Expand All @@ -102,7 +104,7 @@ export class NoteUpdateVisibilityService {
noteUserUsername: user.username,
noteUserHost: user.host,
note: note,
to: { visibility, locaOnly, reactionAcceptance }
to
});
}
}
Expand Down
4 changes: 4 additions & 0 deletions packages/backend/src/server/api/EndpointsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ import * as ep___notes_clips from './endpoints/notes/clips.js';
import * as ep___notes_conversation from './endpoints/notes/conversation.js';
import * as ep___notes_create from './endpoints/notes/create.js';
import * as ep___notes_delete from './endpoints/notes/delete.js';
import * as ep___notes_updateVisibility from './endpoints/notes/update-visibility.js';
import * as ep___notes_favorites_create from './endpoints/notes/favorites/create.js';
import * as ep___notes_favorites_delete from './endpoints/notes/favorites/delete.js';
import * as ep___notes_featured from './endpoints/notes/featured.js';
Expand Down Expand Up @@ -639,6 +640,7 @@ const $notes_clips: Provider = { provide: 'ep:notes/clips', useClass: ep___notes
const $notes_conversation: Provider = { provide: 'ep:notes/conversation', useClass: ep___notes_conversation.default };
const $notes_create: Provider = { provide: 'ep:notes/create', useClass: ep___notes_create.default };
const $notes_delete: Provider = { provide: 'ep:notes/delete', useClass: ep___notes_delete.default };
const $notes_updateVisibility: Provider = { provide: 'ep:notes/update-visibility', useClass: ep___notes_updateVisibility.default };
const $notes_favorites_create: Provider = { provide: 'ep:notes/favorites/create', useClass: ep___notes_favorites_create.default };
const $notes_favorites_delete: Provider = { provide: 'ep:notes/favorites/delete', useClass: ep___notes_favorites_delete.default };
const $notes_featured: Provider = { provide: 'ep:notes/featured', useClass: ep___notes_featured.default };
Expand Down Expand Up @@ -1014,6 +1016,7 @@ const $reversi_verify: Provider = { provide: 'ep:reversi/verify', useClass: ep__
$notes_conversation,
$notes_create,
$notes_delete,
$notes_updateVisibility,
$notes_favorites_create,
$notes_favorites_delete,
$notes_featured,
Expand Down Expand Up @@ -1383,6 +1386,7 @@ const $reversi_verify: Provider = { provide: 'ep:reversi/verify', useClass: ep__
$notes_conversation,
$notes_create,
$notes_delete,
$notes_updateVisibility,
$notes_favorites_create,
$notes_favorites_delete,
$notes_featured,
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/server/api/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ import * as ep___notes_clips from './endpoints/notes/clips.js';
import * as ep___notes_conversation from './endpoints/notes/conversation.js';
import * as ep___notes_create from './endpoints/notes/create.js';
import * as ep___notes_delete from './endpoints/notes/delete.js';
import * as ep___notes_updateVisibility from './endpoints/notes/update-visibility.js';
import * as ep___notes_favorites_create from './endpoints/notes/favorites/create.js';
import * as ep___notes_favorites_delete from './endpoints/notes/favorites/delete.js';
import * as ep___notes_featured from './endpoints/notes/featured.js';
Expand Down Expand Up @@ -637,6 +638,7 @@ const eps = [
['notes/conversation', ep___notes_conversation],
['notes/create', ep___notes_create],
['notes/delete', ep___notes_delete],
['notes/update-visibility', ep___notes_updateVisibility],
['notes/favorites/create', ep___notes_favorites_create],
['notes/favorites/delete', ep___notes_favorites_delete],
['notes/featured', ep___notes_featured],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const paramDef = {
type: 'object',
properties: {
noteId: { type: 'string', format: 'misskey:id' },
visibility: { type: 'string', nullable: true, enum: ['public', 'home', 'followers', 'specified'] },
visibility: { type: 'string', nullable: true, enum: [null, 'public', 'home', 'followers', 'specified'] },
localOnly: { type: 'boolean', nullable: true },
reactionAcceptance: { type: 'string', nullable: true, enum: [null, 'likeOnly', 'likeOnlyForRemote', 'nonSensitiveOnly', 'nonSensitiveOnlyForLocalLikeOnlyForRemote'], default: null },
},
Expand Down Expand Up @@ -73,7 +73,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}

// この操作を行うのが投稿者とは限らない(例えばモデレーター)ため
await this.noteUpdateVisibilityService.updateVisibility(await this.usersRepository.findOneByOrFail({ id: note.userId }), note, false, me);
await this.noteUpdateVisibilityService.updateVisibility(await this.usersRepository.findOneByOrFail({ id: note.userId }), note, ps.visibility, ps.localOnly, ps.reactionAcceptance, false, me);
});
}
}
18 changes: 9 additions & 9 deletions packages/frontend/src/scripts/get-note-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export function getNoteMenu(props: {
function limitToFollowers(): void {
os.confirm({
type: 'warning',
text: i18n.ts.limitToHomeConfirm,
text: i18n.ts.limitToFollowersConfirm,
}).then(({ canceled }) => {
if (canceled) return;

Expand Down Expand Up @@ -485,30 +485,30 @@ export function getNoteMenu(props: {
action: del,
},
{ type: 'divider' },
{
appearNote.visibility === 'public' ? {
icon: 'ti ti-edit',
text: i18n.ts.limitToHome,
danger: true,
action: limitToHome,
},
{
} : undefined,
appearNote.visibility === 'home' ? {
icon: 'ti ti-edit',
text: i18n.ts.limitToFollowers,
danger: true,
action: limitToFollowers,
},
{
} : undefined,
!appearNote.localOnly ? {
icon: 'ti ti-edit',
text: i18n.ts.limitToLocalOnly,
danger: true,
action: limitToLocalOnly,
},
{
} : undefined,
appearNote.reactionAcceptance !== 'likeOnly' ? {
icon: 'ti ti-edit',
text: i18n.ts.limitToLikeOnly,
danger: true,
action: limitToLikeOnly,
},
} : undefined,
]
: []
)
Expand Down
5 changes: 5 additions & 0 deletions packages/misskey-js/src/streaming.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ export type NoteUpdatedEvent = {
reaction: string;
userId: User['id'];
};
} | {
type: 'visibilityUpdated';
body: {
updatedAt: string;
};
} | {
type: 'deleted';
body: {
Expand Down

0 comments on commit b8fe963

Please sign in to comment.