Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

1.4 KB
Raw Blame
import { UserNotificationType } from '@peertube/peertube-models'
import { t } from '@server/helpers/i18n.js'
import { createLogger } from '@server/helpers/logger.js'
import { WEBSERVER } from '@server/initializers/constants.js'
import { MUserWithNotificationSetting } from '@server/types/models/index.js'
import { AbstractChannelChangeOwnershipResponse } from './abstract-channel-change-ownership-response.js'

const logger = createLogger()

export class ChannelChangeOwnershipAccepted extends AbstractChannelChangeOwnershipResponse {
  log () {
    logger.info(
      'Notifying source channel members that ownership change of channel %s was accepted.',
      this.payload.VideoChannel.Actor.preferredUsername
    )
  }

  protected getNotificationType () {
    return UserNotificationType.CHANNEL_OWNERSHIP_CHANGED_ACCEPTED
  }

  createEmail (user: MUserWithNotificationSetting) {
    const language = user.getLanguage()
    const to = { email: user.email, language }

    return {
      to,
      subject: t('A channel ownership change request has been accepted', language),
      text: t('{nextOwner} accepted the ownership change request for channel {channelName}.', language, {
        nextOwner: this.payload.NextOwner.getDisplayName(),
        channelName: this.payload.VideoChannel.name
      }),
      action: {
        text: t('View your notifications', language),
        url: WEBSERVER.URL + '/my-account/notifications'
      }
    }
  }
}