Compare commits
2 Commits
c400895450
...
4917fe11da
Author | SHA1 | Date | |
---|---|---|---|
4917fe11da | |||
f91157467d |
@ -26,7 +26,7 @@
|
||||
"build": "tsc",
|
||||
"buildwatch": "tsc --watch",
|
||||
"clean": "rimraf build",
|
||||
"start": "npm run clean && node build/index.js",
|
||||
"start": "node build/index.js",
|
||||
"debuggable": "node build/index.js --inspect-brk",
|
||||
"monitor": "nodemon build/index.js",
|
||||
"lint": "eslint . --ext .ts",
|
||||
|
@ -25,20 +25,22 @@ export class JellyfinHandler {
|
||||
}
|
||||
constructor(_config: Config, _userApi?: UserApi, _systemApi?: SystemApi) {
|
||||
this.config = _config
|
||||
const userApiConfigurationParams: ConfigurationParameters = {
|
||||
basePath: this.config.bot.jellyfin_url
|
||||
}
|
||||
const systemApiConfigurationParams: ConfigurationParameters = {
|
||||
basePath: this.config.bot.jellyfin_url
|
||||
}
|
||||
this.userApi = _userApi ?? new UserApi(new Configuration(userApiConfigurationParams))
|
||||
this.systemApi = _systemApi ?? new SystemApi(new Configuration(systemApiConfigurationParams))
|
||||
this.token = this.config.bot.jellfin_token
|
||||
this.authHeader = {
|
||||
headers: {
|
||||
"X-MediaBrowser-Token": this.token
|
||||
}
|
||||
}
|
||||
const userApiConfigurationParams: ConfigurationParameters = {
|
||||
basePath: this.config.bot.jellyfin_url,
|
||||
headers: this.authHeader.headers
|
||||
}
|
||||
const systemApiConfigurationParams: ConfigurationParameters = {
|
||||
basePath: this.config.bot.jellyfin_url,
|
||||
headers: this.authHeader.headers
|
||||
}
|
||||
this.userApi = _userApi ?? new UserApi(new Configuration(userApiConfigurationParams))
|
||||
this.systemApi = _systemApi ?? new SystemApi(new Configuration(systemApiConfigurationParams))
|
||||
logger.info(`Initialized Jellyfin handler`, { requestId: 'Init' })
|
||||
}
|
||||
|
||||
@ -51,7 +53,7 @@ export class JellyfinHandler {
|
||||
}
|
||||
|
||||
private generatePasswordForUser(user: GuildMember): string {
|
||||
return user.nickname + user.user.discriminator
|
||||
return user.displayName + user.user.discriminator
|
||||
}
|
||||
|
||||
public async createUserAccountForDiscordUser(discordUser: GuildMember, guildId?: string, requestId?: string): Promise<UserDto> {
|
||||
@ -64,7 +66,7 @@ export class JellyfinHandler {
|
||||
}
|
||||
}
|
||||
logger.debug(JSON.stringify(req))
|
||||
const createResult = await this.userApi.createUserByName(req, this.authHeader)
|
||||
const createResult = await this.userApi.createUserByName(req)
|
||||
if (createResult)
|
||||
return createResult
|
||||
else throw new Error('Could not create User in Jellyfin')
|
||||
@ -79,7 +81,7 @@ export class JellyfinHandler {
|
||||
isDisabled: true
|
||||
},
|
||||
}
|
||||
await this.userApi.updateUserPolicy(r, this.authHeader)
|
||||
await this.userApi.updateUserPolicy(r)
|
||||
logger.info(`Succeeded with disabling user: ${user.name}`)
|
||||
}
|
||||
else {
|
||||
@ -127,7 +129,7 @@ export class JellyfinHandler {
|
||||
updateUserPolicyRequest: {
|
||||
}
|
||||
}
|
||||
await this.userApi.updateUserPolicy(r, this.authHeader)
|
||||
await this.userApi.updateUserPolicy(r)
|
||||
logger.info(`Succeeded with enabling user: ${user.name}`)
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user