Compare commits
No commits in common. "4917fe11da9d81c0326cc3022d0d1bf745557b80" and "c400895450cc6a5f93e4003d88540530a0a3d944" have entirely different histories.
4917fe11da
...
c400895450
@ -26,7 +26,7 @@
|
||||
"build": "tsc",
|
||||
"buildwatch": "tsc --watch",
|
||||
"clean": "rimraf build",
|
||||
"start": "node build/index.js",
|
||||
"start": "npm run clean && node build/index.js",
|
||||
"debuggable": "node build/index.js --inspect-brk",
|
||||
"monitor": "nodemon build/index.js",
|
||||
"lint": "eslint . --ext .ts",
|
||||
|
@ -25,22 +25,20 @@ 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' })
|
||||
}
|
||||
|
||||
@ -53,7 +51,7 @@ export class JellyfinHandler {
|
||||
}
|
||||
|
||||
private generatePasswordForUser(user: GuildMember): string {
|
||||
return user.displayName + user.user.discriminator
|
||||
return user.nickname + user.user.discriminator
|
||||
}
|
||||
|
||||
public async createUserAccountForDiscordUser(discordUser: GuildMember, guildId?: string, requestId?: string): Promise<UserDto> {
|
||||
@ -66,7 +64,7 @@ export class JellyfinHandler {
|
||||
}
|
||||
}
|
||||
logger.debug(JSON.stringify(req))
|
||||
const createResult = await this.userApi.createUserByName(req)
|
||||
const createResult = await this.userApi.createUserByName(req, this.authHeader)
|
||||
if (createResult)
|
||||
return createResult
|
||||
else throw new Error('Could not create User in Jellyfin')
|
||||
@ -81,7 +79,7 @@ export class JellyfinHandler {
|
||||
isDisabled: true
|
||||
},
|
||||
}
|
||||
await this.userApi.updateUserPolicy(r)
|
||||
await this.userApi.updateUserPolicy(r, this.authHeader)
|
||||
logger.info(`Succeeded with disabling user: ${user.name}`)
|
||||
}
|
||||
else {
|
||||
@ -129,7 +127,7 @@ export class JellyfinHandler {
|
||||
updateUserPolicyRequest: {
|
||||
}
|
||||
}
|
||||
await this.userApi.updateUserPolicy(r)
|
||||
await this.userApi.updateUserPolicy(r, this.authHeader)
|
||||
logger.info(`Succeeded with enabling user: ${user.name}`)
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user