mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 17:59:37 +02:00
Add ability to set avatar to instance
This commit is contained in:
parent
db06d13c67
commit
bb7cb0d2fd
29 changed files with 693 additions and 348 deletions
|
@ -1,5 +1,5 @@
|
|||
import { forkJoin, of } from 'rxjs'
|
||||
import { catchError, map, tap } from 'rxjs/operators'
|
||||
import { forkJoin } from 'rxjs'
|
||||
import { catchError, map } from 'rxjs/operators'
|
||||
import { HttpClient } from '@angular/common/http'
|
||||
import { Injectable } from '@angular/core'
|
||||
import { MarkdownService, RestExtractor, ServerService } from '@app/core'
|
||||
|
@ -18,8 +18,6 @@ export class InstanceService {
|
|||
private static BASE_CONFIG_URL = environment.apiUrl + '/api/v1/config'
|
||||
private static BASE_SERVER_URL = environment.apiUrl + '/api/v1/server'
|
||||
|
||||
private instanceBannerUrl: string
|
||||
|
||||
constructor (
|
||||
private authHttp: HttpClient,
|
||||
private restExtractor: RestExtractor,
|
||||
|
@ -30,29 +28,12 @@ export class InstanceService {
|
|||
|
||||
getAbout () {
|
||||
return this.authHttp.get<About>(InstanceService.BASE_CONFIG_URL + '/about')
|
||||
.pipe(
|
||||
tap(about => {
|
||||
const banners = about.instance.banners
|
||||
if (banners.length !== 0) this.instanceBannerUrl = banners[0].path
|
||||
}),
|
||||
catchError(res => this.restExtractor.handleError(res))
|
||||
)
|
||||
.pipe(catchError(res => this.restExtractor.handleError(res)))
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
getInstanceBannerUrl () {
|
||||
if (this.instanceBannerUrl || this.instanceBannerUrl === null) {
|
||||
return of(this.instanceBannerUrl)
|
||||
}
|
||||
|
||||
return this.getAbout()
|
||||
.pipe(map(() => this.instanceBannerUrl))
|
||||
}
|
||||
|
||||
updateInstanceBanner (formData: FormData) {
|
||||
this.instanceBannerUrl = undefined
|
||||
|
||||
const url = InstanceService.BASE_CONFIG_URL + '/instance-banner/pick'
|
||||
|
||||
return this.authHttp.post(url, formData)
|
||||
|
@ -60,8 +41,6 @@ export class InstanceService {
|
|||
}
|
||||
|
||||
deleteInstanceBanner () {
|
||||
this.instanceBannerUrl = null
|
||||
|
||||
const url = InstanceService.BASE_CONFIG_URL + '/instance-banner'
|
||||
|
||||
return this.authHttp.delete(url)
|
||||
|
@ -70,6 +49,22 @@ export class InstanceService {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
updateInstanceAvatar (formData: FormData) {
|
||||
const url = InstanceService.BASE_CONFIG_URL + '/instance-avatar/pick'
|
||||
|
||||
return this.authHttp.post(url, formData)
|
||||
.pipe(catchError(err => this.restExtractor.handleError(err)))
|
||||
}
|
||||
|
||||
deleteInstanceAvatar () {
|
||||
const url = InstanceService.BASE_CONFIG_URL + '/instance-avatar'
|
||||
|
||||
return this.authHttp.delete(url)
|
||||
.pipe(catchError(err => this.restExtractor.handleError(err)))
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
contactAdministrator (fromEmail: string, fromName: string, subject: string, message: string) {
|
||||
const body = {
|
||||
fromEmail,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue