Skip to content

Commit

Permalink
note参照
Browse files Browse the repository at this point in the history
  • Loading branch information
nenohi committed May 6, 2023
1 parent bc63ea4 commit 5ecf9d3
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/backend/src/core/NoteCreateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,7 @@ export class NoteCreateService implements OnApplicationShutdown {

if (data.visibility === 'public' && data.channel == null) {
const sensitiveWords = (await this.metaService.fetch()).sensitiveWords;
if ((data.cw == null) && (data.text != null) && this.isSensitive(data.text!, sensitiveWords)) {
data.visibility = 'home';
} else if ((data.cw != null) && this.isSensitive(data.cw!, sensitiveWords)) {
if (this.isSensitive(data, sensitiveWords)) {
data.visibility = 'home';
} else if ((await this.roleService.getUserPolicies(user.id)).canPublicNote === false) {
data.visibility = 'home';
Expand Down Expand Up @@ -674,8 +672,9 @@ export class NoteCreateService implements OnApplicationShutdown {
}

@bindThis
private isSensitive(text: string, sensitiveWord: string[]): boolean {
private isSensitive(note: Option, sensitiveWord: string[]): boolean {
if (sensitiveWord.length > 0) {
const text = note.cw ?? note.text ?? '';
if (text === '') return false;
const matched = sensitiveWord.some(filter => {
// represents RegExp
Expand Down

0 comments on commit 5ecf9d3

Please sign in to comment.