Merge pull request #35 from anatawa12/no-sensitive-channel-in-user-page

Collapse / hide sensitive channel in user page
This commit is contained in:
anatawa12 2023-08-06 21:44:22 +09:00 committed by GitHub
commit c2eb20c4c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 22 additions and 6 deletions

View File

@ -21,6 +21,7 @@
### Client
- センシティブチャンネルのNoteのReNoteはデフォルトでHome TLに流れるようになりました
- センシティブチャンネルのNoteがユーザページから非表示またはたたまれるようになりました
- Enhance: Renote自体を通報できるように
### Server

View File

@ -48,6 +48,7 @@ export const paramDef = {
type: 'string',
} },
excludeNsfw: { type: 'boolean', default: false },
includeSensitiveChannel: { type: 'boolean', default: true },
},
required: ['userId'],
} as const;
@ -79,6 +80,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.leftJoinAndSelect('reply.user', 'replyUser')
.leftJoinAndSelect('renote.user', 'renoteUser');
if (!ps.includeSensitiveChannel) {
query.leftJoinAndSelect('note.channel', 'channel')
.andWhere(new Brackets((qb) => {
qb.where('channel.isSensitive IS NULL')
.orWhere('channel.isSensitive = FALSE');
}));
}
this.queryService.generateVisibilityQuery(query, me);
if (me) {
this.queryService.generateMutedUserQuery(query, me, user);

View File

@ -175,6 +175,7 @@ import { notePage } from '@/filters/note';
const props = defineProps<{
note: misskey.entities.Note;
pinned?: boolean;
collapseSensitiveChannel?: boolean;
}>();
const inChannel = inject('inChannel', null);
@ -210,7 +211,7 @@ let appearNote = $computed(() => isRenote ? note.renote as misskey.entities.Note
const isMyRenote = $i && ($i.id === note.userId);
const showContent = ref(false);
const urls = appearNote.text ? extractUrlFromMfm(mfm.parse(appearNote.text)) : null;
const isLong = shouldCollapsed(appearNote);
const isLong = shouldCollapsed(appearNote, props.collapseSensitiveChannel ?? false);
const collapsed = ref(appearNote.cw == null && isLong);
const isDeleted = ref(false);
const muted = ref(checkWordMute(appearNote, $i, defaultStore.state.mutedWords));

View File

@ -19,7 +19,7 @@
:ad="true"
:class="$style.notes"
>
<MkNote :key="note._featuredId_ || note._prId_ || note.id" :class="$style.note" :note="note"/>
<MkNote :key="note._featuredId_ || note._prId_ || note.id" :class="$style.note" :note="note" :collapseSensitiveChannel="props.collapseSensitiveChannel"/>
</MkDateSeparatedList>
</div>
</template>
@ -37,6 +37,7 @@ import { infoImageUrl } from '@/instance';
const props = defineProps<{
pagination: Paging;
noGap?: boolean;
collapseSensitiveChannel?: boolean;
}>();
const pagingComponent = shallowRef<InstanceType<typeof MkPagination>>();

View File

@ -125,7 +125,7 @@
<XPhotos :key="user.id" :user="user"/>
<XActivity :key="user.id" :user="user"/>
</template>
<MkNotes v-if="!disableNotes" :class="$style.tl" :noGap="true" :pagination="pagination"/>
<MkNotes v-if="!disableNotes" :class="$style.tl" :noGap="true" :pagination="pagination" :collapseSensitiveChannel="true"/>
</div>
</div>
<div v-if="!narrow" class="sub _gaps" style="container-type: inline-size;">
@ -194,6 +194,7 @@ const pagination = {
limit: 10,
params: computed(() => ({
userId: props.user.id,
includeSensitiveChannel: $i != null,
})),
};

View File

@ -8,7 +8,7 @@
<option value="files">{{ i18n.ts.withFiles }}</option>
</MkTab>
</template>
<MkNotes :noGap="true" :pagination="pagination" :class="$style.tl"/>
<MkNotes :noGap="true" :pagination="pagination" :class="$style.tl" :collapseSensitiveChannel="true"/>
</MkStickyContainer>
</MkSpacer>
</template>
@ -19,6 +19,7 @@ import * as misskey from 'misskey-js';
import MkNotes from '@/components/MkNotes.vue';
import MkTab from '@/components/MkTab.vue';
import { i18n } from '@/i18n';
import { $i } from '@/account';
const props = defineProps<{
user: misskey.entities.UserDetailed;
@ -33,6 +34,7 @@ const pagination = {
userId: props.user.id,
includeReplies: include.value === 'replies' || include.value === 'files',
withFiles: include.value === 'files',
includeSensitiveChannel: $i != null,
})),
};
</script>

View File

@ -2,7 +2,7 @@ import * as mfm from 'mfm-js';
import * as misskey from 'misskey-js';
import { extractUrlFromMfm } from './extract-url-from-mfm';
export function shouldCollapsed(note: misskey.entities.Note): boolean {
export function shouldCollapsed(note: misskey.entities.Note, collapseSensitiveChannel = false): boolean {
const urls = note.text ? extractUrlFromMfm(mfm.parse(note.text)) : null;
const collapsed = note.cw == null && note.text != null && (
(note.text.includes('$[x2')) ||
@ -12,7 +12,8 @@ export function shouldCollapsed(note: misskey.entities.Note): boolean {
(note.text.split('\n').length > 9) ||
(note.text.length > 500) ||
(note.files.length >= 5) ||
(!!urls && urls.length >= 4)
(!!urls && urls.length >= 4) ||
collapseSensitiveChannel ? note.channel?.isSensitive : false
);
return collapsed;