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