]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Remove useless async
authorChocobozzz <me@florianbigard.com>
Wed, 25 Aug 2021 14:14:11 +0000 (16:14 +0200)
committerChocobozzz <me@florianbigard.com>
Thu, 26 Aug 2021 08:01:42 +0000 (10:01 +0200)
35 files changed:
.eslintrc.json
client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
client/src/app/+admin/follows/following-list/follow-modal.component.ts
client/src/app/+admin/moderation/video-comment-list/video-comment-list.component.ts
client/src/app/+admin/users/user-list/user-list.component.ts
client/src/app/+home/home.component.ts
client/src/app/+search/search.component.ts
client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts
client/src/app/+videos/+video-edit/shared/video-edit.component.ts
client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts
client/src/app/+videos/+video-watch/video-watch.component.ts
client/src/app/app.component.ts
client/src/app/core/notification/peertube-socket.service.ts
client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts
client/src/app/shared/shared-main/misc/top-menu-dropdown.component.ts
client/src/app/shared/shared-moderation/user-ban-modal.component.ts
client/src/assets/player/stats/stats-card.ts
client/src/assets/player/webtorrent/peertube-chunk-store.ts
client/src/standalone/videos/embed.ts
client/src/standalone/videos/test-embed.ts
server/controllers/api/video-channel.ts
server/controllers/api/videos/index.ts
server/controllers/api/videos/live.ts
server/helpers/ffmpeg-utils.ts
server/lib/auth/oauth.ts
server/lib/live/shared/muxing-session.ts
server/lib/moderation.ts
server/lib/notifier/shared/follow/auto-follow-for-instance.ts
server/lib/notifier/shared/follow/follow-for-instance.ts
server/lib/notifier/shared/follow/follow-for-user.ts
server/lib/notifier/shared/instance/new-peertube-version-for-admins.ts
server/lib/notifier/shared/instance/new-plugin-version-for-admins.ts
server/lib/notifier/shared/instance/registration-for-moderators.ts
server/lib/transcoding/video-transcoding-profiles.ts
server/tools/peertube-import-videos.ts

index 042254c95aca67a6a98b23bfad954568591f9e75..a49a9e71b4a190cfc2704f039d0c94b5c60c8bab 100644 (file)
     "@typescript-eslint/no-empty-interface": "off",
     "@typescript-eslint/no-extraneous-class": "off",
     "@typescript-eslint/no-use-before-define": "off",
+
+    "require-await": "off",
+    "@typescript-eslint/require-await": "error",
+
     // bugged but useful
     "@typescript-eslint/restrict-plus-operands": "off"
   },
index be1a992894e422b81cb4a9fb18dfa1e5158d391f..f13fe4bf943ad80f720889606ff9ede9c980d6e8 100644 (file)
@@ -260,7 +260,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
     this.loadCategoriesAndLanguages()
   }
 
-  async formValidated () {
+  formValidated () {
     const value: ComponentCustomConfig = this.form.getRawValue()
 
     forkJoin([
index c55fc8d81f2380066dc88a8dbebf48e4e6cd8f1e..c40b36e1012f0d2ff2783292bdb9d8963c532214 100644 (file)
@@ -54,7 +54,7 @@ export class FollowModalComponent extends FormReactive implements OnInit {
     return window.location.protocol === 'https:'
   }
 
-  private async addFollowing () {
+  private addFollowing () {
     const hostsOrHandles = splitAndGetNotEmpty(this.form.value['hostsOrHandles'])
 
     this.followService.follow(hostsOrHandles)
index 512ceffd98bab85a6fc043c0969c50e86c1b9329..c09ce7293045cd388723e081c713f81ad8c6cc39 100644 (file)
@@ -134,7 +134,7 @@ export class VideoCommentListComponent extends RestTable implements OnInit {
     })
   }
 
-  private async removeComments (comments: VideoCommentAdmin[]) {
+  private removeComments (comments: VideoCommentAdmin[]) {
     const commentArgs = comments.map(c => ({ videoId: c.video.id, commentId: c.id }))
 
     this.videoCommentService.deleteVideoComments(commentArgs)
index 39caf5ed519787c9f93ad44cdd5cbc2cc71a73c4..1030759df52be43c00079bda291d977cd2b4d9dc 100644 (file)
@@ -206,7 +206,7 @@ export class UserListComponent extends RestTable implements OnInit {
       })
   }
 
-  async setEmailsAsVerified (users: User[]) {
+  setEmailsAsVerified (users: User[]) {
     this.userService.updateUsers(users, { emailVerified: true })
       .subscribe({
         next: () => {
index 6e0c96760b95bf324e34f46080af0f03d1fbd98d..f966a2b024e11626183f81946107f54ca1798eee 100644 (file)
@@ -15,7 +15,7 @@ export class HomeComponent implements OnInit {
     private customPageService: CustomPageService
   ) { }
 
-  async ngOnInit () {
+  ngOnInit () {
     this.customPageService.getInstanceHomepage()
       .subscribe(({ content }) => this.homepageContent = content)
   }
index 81d1006f8ea0840788cbe167e8f05728182ca9dc..fcf6ebbec77c40202159962b1580d4e2890a4f10 100644 (file)
@@ -75,7 +75,7 @@ export class SearchComponent implements OnInit, OnDestroy {
 
     this.subActivatedRoute = this.route.queryParams
       .subscribe({
-        next: async queryParams => {
+        next: queryParams => {
           const querySearch = queryParams['search']
           const searchTarget = queryParams['searchTarget']
 
index 98d66ff00db633afd7afec111a144b3342a11f13..5c4152884ab038067158474da14bf5b9456e4a03 100644 (file)
@@ -71,7 +71,7 @@ export class VideoCaptionAddModalComponent extends FormReactive implements OnIni
     return languageId && this.existingCaptions.includes(languageId)
   }
 
-  async addCaption () {
+  addCaption () {
     const languageId = this.form.value['language']
     const languageObject = this.videoCaptionLanguages.find(l => l.id === languageId)
 
index 366c93a7936ac26d22185675e6ee31372df18308..bf7fdeeed438971777ad4c1387106732e2916889 100644 (file)
@@ -231,7 +231,7 @@ export class VideoEditComponent implements OnInit, OnDestroy {
     this.sortVideoCaptions()
   }
 
-  async deleteCaption (caption: VideoCaptionEdit) {
+  deleteCaption (caption: VideoCaptionEdit) {
     // Caption recovers his former state
     if (caption.action && this.initialVideoCaptions.includes(caption.language.id)) {
       caption.action = undefined
index ef5c8ed876758c9ea955f0518dd20a4fdfeb1d06..b1e8bf989e1c3476af8e9d6867dff2ae331fa5ef 100644 (file)
@@ -21,8 +21,9 @@ export class PrivacyConcernsComponent implements OnInit {
     private serverService: ServerService
   ) { }
 
-  async ngOnInit () {
+  ngOnInit () {
     this.serverConfig = this.serverService.getHTMLConfig()
+
     if (
       isWebRTCDisabled() ||
       this.serverConfig.tracker.enabled === false ||
index 2007bdecbdb72b7788e9f1c13991e9550d2eb7d0..acfd46a41a32249c9cad10457a23c42e728bbd09 100644 (file)
@@ -113,7 +113,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
     return this.userService.getAnonymousUser()
   }
 
-  async ngOnInit () {
+  ngOnInit () {
     this.serverConfig = this.serverService.getHTMLConfig()
 
     PeertubePlayerManager.initState()
@@ -640,7 +640,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
     }
 
     if (oldVideo && oldVideo.id !== newVideo.id) {
-      await this.peertubeSocket.unsubscribeLiveVideos(oldVideo.id)
+      this.peertubeSocket.unsubscribeLiveVideos(oldVideo.id)
     }
 
     if (!newVideo.isLive) return
index 4d5a9f75f0e13d8d305d27c7b5bbac58db95cf25..ae6046cc1f7de52207898ecee96d011337c383d1 100644 (file)
@@ -220,7 +220,7 @@ export class AppComponent implements OnInit, AfterViewInit {
     }
   }
 
-  private async openModalsIfNeeded () {
+  private openModalsIfNeeded () {
     this.authService.userInformationLoaded
         .pipe(
           map(() => this.authService.getUser()),
@@ -232,7 +232,7 @@ export class AppComponent implements OnInit, AfterViewInit {
         ).subscribe(({ serverConfig, user }) => this._openAdminModalsIfNeeded(serverConfig, user))
   }
 
-  private async _openAdminModalsIfNeeded (serverConfig: ServerConfig, user: User) {
+  private _openAdminModalsIfNeeded (serverConfig: ServerConfig, user: User) {
     if (user.noWelcomeModal !== true) return this.welcomeModal.show()
 
     if (user.noInstanceConfigWarningModal === true || !serverConfig.signup.allowed) return
index eab1c63f24f9b1654233355d9c6674de22cf62e6..50d5df68f49853ae33ea4b7be8369fce3c359f42 100644 (file)
@@ -38,7 +38,7 @@ export class PeerTubeSocket {
     this.liveVideosSocket.emit('subscribe', { videoId })
   }
 
-  async unsubscribeLiveVideos (videoId: number) {
+  unsubscribeLiveVideos (videoId: number) {
     if (!this.liveVideosSocket) return
 
     this.liveVideosSocket.emit('unsubscribe', { videoId })
index ccb0c5262ac111ecb0f4713f13b4a3756cf78ff1..2600da8dad9505315a3cc4c549ffb2b2a4e7d32f 100644 (file)
@@ -49,7 +49,7 @@ export class ModerationCommentModalComponent extends FormReactive implements OnI
     this.form.reset()
   }
 
-  async banUser () {
+  banUser () {
     const moderationComment: string = this.form.value['moderationComment']
 
     this.abuseService.updateAbuse(this.abuseToComment, { moderationComment })
index e7e34ce1ed30b782db85c3ce871279422e56e810..a8cc9b593fa9d263536eb7f0bac5afba676622a6 100644 (file)
@@ -84,8 +84,9 @@ export class TopMenuDropdownComponent implements OnInit, OnDestroy {
 
     this.modalService.open(this.modal, {
       centered: true,
-      beforeDismiss: async () => {
+      beforeDismiss: () => {
         this.onModalDismiss()
+
         return true
       }
     })
index 0a2d5e93a4d4b112890a619da948052bd7b1d84d..a03bd728674a6c52296c188e843c2c700e74d56b 100644 (file)
@@ -43,7 +43,7 @@ export class UserBanModalComponent extends FormReactive implements OnInit {
     this.openedModal.close()
   }
 
-  async banUser () {
+  banUser () {
     const reason = this.form.value['reason'] || undefined
 
     this.userService.banUsers(this.usersToBan, reason)
index a32f6fb979ad7d6b32bc8413588f925abada361c..45fd30d5525991d14e4fa629680dffb89c3bfb73 100644 (file)
@@ -86,7 +86,7 @@ class StatsCard extends Component {
     this.updateInterval = setInterval(async () => {
       try {
         const options = this.mode === 'p2p-media-loader'
-          ? await this.buildHLSOptions()
+          ? this.buildHLSOptions()
           : await this.buildWebTorrentOptions() // Default
 
         this.list.innerHTML = this.getListTemplate(options)
@@ -102,7 +102,7 @@ class StatsCard extends Component {
     this.container.style.display = 'none'
   }
 
-  private async buildHLSOptions () {
+  private buildHLSOptions () {
     const p2pMediaLoader = this.player_.p2pMediaLoader()
     const level = p2pMediaLoader.getCurrentLevel()
 
index 93ca8e1d8486ba1713112a012d32dbc04f4a2980..81378c2777ccac5debb6d46ad2fbf3e1005f0f99 100644 (file)
@@ -184,7 +184,7 @@ export class PeertubeChunkStore extends EventEmitter {
   private runCleaner () {
     this.checkExpiration()
 
-    this.cleanerInterval = setInterval(async () => {
+    this.cleanerInterval = setInterval(() => {
       this.checkExpiration()
     }, PeertubeChunkStore.CLEANER_INTERVAL_MS)
   }
index f35f4a23abd33a7afe65ca577e78232555270ec7..36480922ec4f924acb3727cad9d22f0390d2bf38 100644 (file)
@@ -589,7 +589,7 @@ export class PeerTubeEmbed {
 
     this.buildCSS()
 
-    await this.buildDock(videoInfo)
+    this.buildDock(videoInfo)
 
     this.initializeApi()
 
@@ -665,7 +665,7 @@ export class PeerTubeEmbed {
     }
   }
 
-  private async buildDock (videoInfo: VideoDetails) {
+  private buildDock (videoInfo: VideoDetails) {
     if (!this.controls) return
 
     // On webtorrent fallback, player may have been disposed
index a051f1f89d75974fbd6320b15e081738f73b4edb..301c95d7b56b1dd2347a6a8fcf762de33ace9517 100644 (file)
@@ -47,7 +47,7 @@ window.addEventListener('load', async () => {
   let playbackRates: number[] = []
   let currentRate = await player.getPlaybackRate()
 
-  const updateRates = async () => {
+  const updateRates = () => {
     const rateListEl = document.querySelector('#rate-list')
     rateListEl.innerHTML = ''
 
index 7bdb337370f1145692c41b179031359677f73b1d..a0c6601d94f920c5d5f9360fa34eb0819f9edcd1 100644 (file)
@@ -108,7 +108,7 @@ videoChannelRouter.delete('/:nameWithHost',
 
 videoChannelRouter.get('/:nameWithHost',
   asyncMiddleware(videoChannelsNameWithHostValidator),
-  asyncMiddleware(getVideoChannel)
+  getVideoChannel
 )
 
 videoChannelRouter.get('/:nameWithHost/video-playlists',
@@ -281,7 +281,7 @@ async function removeVideoChannel (req: express.Request, res: express.Response)
   return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
 }
 
-async function getVideoChannel (req: express.Request, res: express.Response) {
+function getVideoChannel (req: express.Request, res: express.Response) {
   const videoChannel = res.locals.videoChannel
 
   if (videoChannel.isOutdated()) {
index 49490f79b13c3579918f0f47d337d47cd88f97d1..10833d48bfdbe7fc524fbb07ef17447dfc35c519 100644 (file)
@@ -102,7 +102,7 @@ videosRouter.get('/:id',
   optionalAuthenticate,
   asyncMiddleware(videosCustomGetValidator('for-api')),
   asyncMiddleware(checkVideoFollowConstraints),
-  asyncMiddleware(getVideo)
+  getVideo
 )
 videosRouter.post('/:id/views',
   openapiOperationDoc({ operationId: 'addView' }),
@@ -141,7 +141,7 @@ function listVideoPrivacies (_req: express.Request, res: express.Response) {
   res.json(VIDEO_PRIVACIES)
 }
 
-async function getVideo (_req: express.Request, res: express.Response) {
+function getVideo (_req: express.Request, res: express.Response) {
   const video = res.locals.videoAPI
 
   if (video.isOutdated()) {
index ed4da8f479ad3154bd545e57b90d88872256b7fe..151ff354b7b3f6e5cc6292131e6bc565934ec797 100644 (file)
@@ -39,7 +39,7 @@ liveRouter.post('/live',
 liveRouter.get('/live/:videoId',
   authenticate,
   asyncMiddleware(videoLiveGetValidator),
-  asyncRetryTransactionMiddleware(getLiveVideo)
+  getLiveVideo
 )
 
 liveRouter.put('/live/:videoId',
@@ -57,7 +57,7 @@ export {
 
 // ---------------------------------------------------------------------------
 
-async function getLiveVideo (req: express.Request, res: express.Response) {
+function getLiveVideo (req: express.Request, res: express.Response) {
   const videoLive = res.locals.videoLive
 
   return res.json(videoLive.toFormattedJSON())
index 830625cc61cfd283ce183e697c31f8ea8d32448c..a99c9ee7c70809a35c5e87b26356f4fc9ba191ba 100644 (file)
@@ -474,7 +474,7 @@ async function buildHLSVODCommand (command: ffmpeg.FfmpegCommand, options: HLSTr
   return command
 }
 
-async function buildHLSVODFromTSCommand (command: ffmpeg.FfmpegCommand, options: HLSFromTSTranscodeOptions) {
+function buildHLSVODFromTSCommand (command: ffmpeg.FfmpegCommand, options: HLSFromTSTranscodeOptions) {
   const videoPath = getHLSVideoPath(options)
 
   command.outputOption('-c copy')
index 5b6130d567301d802ea49292b508911e38ad4395..a97681c86b76e30bea5af1b668ae838754015d31 100644 (file)
@@ -81,7 +81,7 @@ async function handleOAuthToken (req: express.Request, options: { refreshTokenAu
   })
 }
 
-async function handleOAuthAuthenticate (
+function handleOAuthAuthenticate (
   req: express.Request,
   res: express.Response,
   authenticateInQuery = false
index 9b5b6c4fc99c29abff715d9982fbd6ce336536b4..0c9fb0cb633a86b6c986b4e659cb11392926179a 100644 (file)
@@ -199,7 +199,7 @@ class MuxingSession extends EventEmitter {
   private watchMasterFile (outPath: string) {
     this.masterWatcher = chokidar.watch(outPath + '/' + this.streamingPlaylist.playlistFilename)
 
-    this.masterWatcher.on('add', async () => {
+    this.masterWatcher.on('add', () => {
       this.emit('master-playlist-created', { videoId: this.videoId })
 
       this.masterWatcher.close()
index a42ab5b7ff66acbace7494c664a3f4c38c1c841f..456b615b22bf08cbae488e2382036b6e228b2a64 100644 (file)
@@ -170,8 +170,8 @@ function createAccountAbuse (options: {
 }) {
   const { baseAbuse, accountInstance, transaction, reporterAccount } = options
 
-  const associateFun = async () => {
-    return { isOwned: accountInstance.isOwned() }
+  const associateFun = () => {
+    return Promise.resolve({ isOwned: accountInstance.isOwned() })
   }
 
   return createAbuse({
index 16cc62984d9723915a3bdfbca25f761cb1f53c9c..01d2b3563190f5faa93d43fd8088b385d776af24 100644 (file)
@@ -35,7 +35,7 @@ export class AutoFollowForInstance extends AbstractNotification <MActorFollowFul
     return notification
   }
 
-  async createEmail (to: string) {
+  createEmail (to: string) {
     const instanceUrl = this.actorFollow.ActorFollowing.url
 
     return {
index 9ab269cf10100e12b3aba43d6d1839c184b0817b..a4a2fbf53717093836c85d03d2984fbd42386491 100644 (file)
@@ -43,7 +43,7 @@ export class FollowForInstance extends AbstractNotification <MActorFollowFull> {
     return notification
   }
 
-  async createEmail (to: string) {
+  createEmail (to: string) {
     const awaitingApproval = this.actorFollow.state === 'pending'
       ? ' awaiting manual approval.'
       : ''
index 2d0f675a822f4163f5bde9bb5358e3fa181599f9..e579d448770b89d152ad0401a785797e90e5b3dd 100644 (file)
@@ -56,7 +56,7 @@ export class FollowForUser extends AbstractNotification <MActorFollowFull> {
     return notification
   }
 
-  async createEmail (to: string) {
+  createEmail (to: string) {
     const following = this.actorFollow.ActorFollowing
     const follower = this.actorFollow.ActorFollower
 
index ab5bfb1acb136bff465579e48452ef5b0def7b9e..6b5ac808a0b47ff8ca7a0c48a9a21b39b380e085 100644 (file)
@@ -41,7 +41,7 @@ export class NewPeerTubeVersionForAdmins extends AbstractNotification <NewPeerTu
     return notification
   }
 
-  async createEmail (to: string) {
+  createEmail (to: string) {
     return {
       to,
       template: 'peertube-version-new',
index e5e456a70259b03c56681538651ceee6637a4157..874b10a3deeff276b4372dec9b3b3e8d508b3cf5 100644 (file)
@@ -37,7 +37,7 @@ export class NewPluginVersionForAdmins extends AbstractNotification <MPlugin> {
     return notification
   }
 
-  async createEmail (to: string) {
+  createEmail (to: string) {
     const pluginUrl = WEBSERVER.URL + '/admin/plugins/list-installed?pluginType=' + this.plugin.type
 
     return {
index 4deb5a2cce7f1ceebadf44ee8e500eaf79975fc0..2a48ef2fa51dd1c00185366c55e5c4c14dedd599 100644 (file)
@@ -36,7 +36,7 @@ export class RegistrationForModerators extends AbstractNotification <MUserDefaul
     return notification
   }
 
-  async createEmail (to: string) {
+  createEmail (to: string) {
     return {
       template: 'user-registered',
       to,
index bca6dfccd00a607ce1ffac8e441a6dc9adc554f4..a8176dca56dd33f0042d9893b7f05e210c251171 100644 (file)
@@ -14,7 +14,7 @@ import { canDoQuickAudioTranscode, ffprobePromise, getAudioStream, getMaxAudioBi
  *  * https://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate
  */
 
-const defaultX264VODOptionsBuilder: EncoderOptionsBuilder = async (options: EncoderOptionsBuilderParams) => {
+const defaultX264VODOptionsBuilder: EncoderOptionsBuilder = (options: EncoderOptionsBuilderParams) => {
   const { fps, inputRatio, inputBitrate } = options
   if (!fps) return { outputOptions: [ ] }
 
@@ -30,7 +30,7 @@ const defaultX264VODOptionsBuilder: EncoderOptionsBuilder = async (options: Enco
   }
 }
 
-const defaultX264LiveOptionsBuilder: EncoderOptionsBuilder = async (options: EncoderOptionsBuilderParams) => {
+const defaultX264LiveOptionsBuilder: EncoderOptionsBuilder = (options: EncoderOptionsBuilderParams) => {
   const { streamNum, fps, inputBitrate, inputRatio } = options
 
   const targetBitrate = capBitrate(inputBitrate, getAverageBitrate({ ...options, fps, ratio: inputRatio }))
index 52aae3d2c372cd51783376ec3dd0d0ea82bde4af..488109b7a7ffec1de0491c88b6a3e5dbcc788663 100644 (file)
@@ -407,7 +407,7 @@ function getYoutubeDLInfo (youtubeDL: any, url: string, args: string[]) {
   return new Promise<any>((res, rej) => {
     const options = [ '-j', '--flat-playlist', '--playlist-reverse', ...args ]
 
-    youtubeDL.getInfo(url, options, processOptions, async (err, info) => {
+    youtubeDL.getInfo(url, options, processOptions, (err, info) => {
       if (err) return rej(err)
 
       return res(info)