-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cabf832
commit 72f6b09
Showing
13 changed files
with
6,736 additions
and
3,313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules/ | ||
dist/ | ||
submodule/ | ||
|
||
.tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
apps/back-end/src/module/youtube/util/youtube-chat-handler.util.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Track } from '@app/track' | ||
import { UserFilter, UserFilterType } from '@app/user' | ||
|
||
export class TrackHandlerUtil { | ||
public static canRelay( | ||
track: Pick<Track, 'sourceId' | 'filterId' | 'filterKeywords'>, | ||
authorId: string, | ||
hostId: string, | ||
message: string, | ||
userFilter?: Pick<UserFilter, 'type'>, | ||
) { | ||
// eslint-disable-next-line no-param-reassign | ||
message = message || '' | ||
|
||
if (authorId === hostId) { | ||
if (authorId === track.filterId) { | ||
return false | ||
} | ||
|
||
if (authorId === track.sourceId && track.filterId) { | ||
return false | ||
} | ||
} | ||
|
||
if (userFilter) { | ||
return userFilter.type === UserFilterType.ALLOW | ||
} | ||
|
||
if (authorId !== track.sourceId && authorId !== track.filterId) { | ||
return false | ||
} | ||
|
||
if (authorId === track.filterId) { | ||
if (hostId !== track.sourceId && track.sourceId) { | ||
return false | ||
} | ||
|
||
if ( | ||
track.filterKeywords?.length | ||
&& !track.filterKeywords.some((keyword) => message.toLowerCase().includes(keyword.toLowerCase())) | ||
) { | ||
return false | ||
} | ||
} | ||
|
||
return true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
|
||
const { pathsToModuleNameMapper } = require('ts-jest') | ||
const { compilerOptions } = require('./tsconfig') | ||
|
||
module.exports = { | ||
verbose: true, | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
moduleFileExtensions: ['js', 'json', 'ts'], | ||
moduleNameMapper: { | ||
...pathsToModuleNameMapper(compilerOptions.paths), | ||
'^masterchat$': '<rootDir>/submodule/masterchat/src', | ||
}, | ||
modulePaths: ['<rootDir>'], | ||
testRegex: '.*\\.spec\\.ts$', | ||
transform: { '^.+\\.(t|j)s$': 'ts-jest' }, | ||
coverageDirectory: '../coverage', | ||
collectCoverageFrom: ['**/*.(t|j)s'], | ||
} |
Oops, something went wrong.