ActivityPub-federated video streaming platform using P2P directly in your web browser
Cancel a ownership change request in manage page
Chocobozzz868cde3629ee
diff --git a/client/src/app/+my-library/+my-video-channels/edit/pages/video-channel-activity.component.html b/client/src/app/+my-library/+my-video-channels/edit/pages/video-channel-activity.component.htmlindex 92a17aa760..de7765d7d4 100644--- a/client/src/app/+my-library/+my-video-channels/edit/pages/video-channel-activity.component.html+++ b/client/src/app/+my-library/+my-video-channels/edit/pages/video-channel-activity.component.html@@ -200,6 +200,12 @@<strong>{{ account }}</strong> updated embed policy of video <a [routerLink]="[ '/w', a.video.shortUUID ]">{{ a.video.name }}</a></ng-container>}++ @case (16) { <!-- VideoChannelActivityAction.DELETE_OWNERSHIP_REQUEST) -->+ <ng-container i18n>+ <strong>{{ account }}</strong> deleted an ownership request for video <a [routerLink]="[ '/w', a.video.shortUUID ]">{{ a.video.name }}</a>+ </ng-container>+ }}</div>diff --git a/client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.ts b/client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.tsindex 31bccb9c24..1eb5f0b9b9 100644--- a/client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.ts+++ b/client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.ts@@ -66,7 +66,7 @@ export class MyAcceptOwnershipComponent extends FormReactive implements OnInit {const videoChangeOwnership = this.videoChangeOwnershipthis.videoOwnershipService- .acceptOwnership(videoChangeOwnership.id, { channelId: channel })+ .accept(videoChangeOwnership.id, { channelId: channel }).subscribe({next: () => {this.notifier.success($localize`Ownership accepted`)diff --git a/client/src/app/+my-library/my-ownership/my-ownership.component.ts b/client/src/app/+my-library/my-ownership/my-ownership.component.tsindex 341c90ce01..d77881e781 100644--- a/client/src/app/+my-library/my-ownership/my-ownership.component.ts+++ b/client/src/app/+my-library/my-ownership/my-ownership.component.ts@@ -68,7 +68,7 @@ export class MyOwnershipComponent {}refuse (videoChangeOwnership: VideoChangeOwnership) {- this.videoOwnershipService.refuseOwnership(videoChangeOwnership.id)+ this.videoOwnershipService.refuse(videoChangeOwnership.id).subscribe({next: () => this.table().loadData(),error: err => this.notifier.handleError(err)@@ -80,7 +80,7 @@ export class MyOwnershipComponent {}private _dataLoader (options: DataLoaderOptionsBase) {- return this.videoOwnershipService.getOwnershipChanges(options.pagination, options.sort)+ return this.videoOwnershipService.list(options.pagination, options.sort).pipe(map(resultList => ({data: resultList.data.map(change => ({diff --git a/client/src/app/+my-library/my-videos/modals/video-change-ownership.component.ts b/client/src/app/+my-library/my-videos/modals/video-change-ownership.component.tsindex d791b3f59b..624fbca046 100644--- a/client/src/app/+my-library/my-videos/modals/video-change-ownership.component.ts+++ b/client/src/app/+my-library/my-videos/modals/video-change-ownership.component.ts@@ -7,7 +7,9 @@ import { FormReactiveService } from '@app/shared/shared-forms/form-reactive.servimport { UserAutoCompleteComponent } from '@app/shared/shared-forms/user-auto-complete.component'import { VideoOwnershipService } from '@app/shared/shared-main/video/video-ownership.service'import { NgbModal } from '@ng-bootstrap/ng-bootstrap'+import { VideoChangeOwnership, VideoChangeOwnershipStatus } from '@peertube/peertube-models'import { AutoCompleteModule } from 'primeng/autocomplete'+import { switchMap } from 'rxjs'import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'@Component({@@ -23,7 +25,7 @@ export class VideoChangeOwnershipComponent extends FormReactive implements OnIniprivate modalService = inject(NgbModal)videoId = input.required<number>()- requestSent = output<string>()+ requestSent = output<VideoChangeOwnership>()readonly modal = viewChild<ElementRef>('modal')@@ -47,10 +49,11 @@ export class VideoChangeOwnershipComponent extends FormReactive implements OnIniconst username = this.form.value['username']this.videoOwnershipService- .changeOwnership(this.videoId(), username)+ .sendChangeRequest(this.videoId(), username)+ .pipe(switchMap(() => this.videoOwnershipService.listFromVideo(this.videoId(), VideoChangeOwnershipStatus.WAITING))).subscribe({- next: () => {- this.requestSent.emit(username)+ next: ({ data }) => {+ this.requestSent.emit(data[0])},error: err => this.notifier.handleError(err)diff --git a/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.html b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.htmlindex ae7519800d..7632137bbe 100644--- a/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.html+++ b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.html@@ -201,14 +201,17 @@<label i18n for="deleteVideo">Change ownership of your video</label><div class="form-group-description" i18n>A modal window will open for you to specify the local account to which you want to transfer your video</div>- <button type="button" class="peertube-button danger-button" (click)="showChangeOwnershipModal()" [disabled]="ownershipRequestSent" i18n>Transfer ownership</button>+ <button type="button" class="peertube-button danger-button" (click)="showChangeOwnershipModal()" [disabled]="!!pendingOwnershipRequest" i18n>Transfer ownership</button>- @if (ownershipRequestSent) {- <my-alert class="d-block mt-3" type="success">- <ng-container i18n>- <a routerLink="/my-library/ownership">Ownership change request</a> sent to {{ ownershipRequestSent }}</ng-container>- </my-alert>- }+ @if (pendingOwnershipRequest) {+ <my-alert class="d-block mt-3 d-flex" type="success">+ <div class="d-flex align-items-center gap-2 flex-wrap">+ <div i18n>Ownership change request sent to <strong>{{pendingOwnershipRequest.nextOwnerAccount.name}}</strong>, awaiting its approval.</div>++ <my-button (click)="cancelOwnershipRequest()" theme="secondary">Cancel request</my-button>+ </div>+ </my-alert>+ }</div><my-video-change-ownershipdiff --git a/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.ts b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.tsindex 3036cd9f64..9d323c1613 100644--- a/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.ts+++ b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.ts@@ -27,15 +27,19 @@ import { PeertubeCheckboxComponent } from '@app/shared/shared-forms/peertube-cheimport { SelectChannelComponent } from '@app/shared/shared-forms/select/select-channel.component'import { SelectOptionsComponent } from '@app/shared/shared-forms/select/select-options.component'import { SelectTagsComponent } from '@app/shared/shared-forms/select/select-tags.component'+import { ButtonComponent } from '@app/shared/shared-main/buttons/button.component'import { AlertComponent } from '@app/shared/shared-main/common/alert.component'import { PeerTubeTemplateDirective } from '@app/shared/shared-main/common/peertube-template.directive'import { InstanceService } from '@app/shared/shared-main/instance/instance.service'+import { VideoOwnershipService } from '@app/shared/shared-main/video/video-ownership.service'import { VideoService } from '@app/shared/shared-main/video/video.service'import {ConstantLabel,HTMLServerConfig,RegisterClientFormFieldOptions,RegisterClientVideoFieldOptions,+ VideoChangeOwnership,+ VideoChangeOwnershipStatus,VideoPrivacy,VideoPrivacyType} from '@peertube/peertube-models'@@ -103,7 +107,8 @@ type Form = {MarkdownHintComponent,RouterLink,VideoChangeOwnershipComponent,- AlertComponent+ AlertComponent,+ ButtonComponent]})export class VideoMainInfoComponent implements OnInit, OnDestroy {@@ -122,6 +127,7 @@ export class VideoMainInfoComponent implements OnInit, OnDestroy {private confirmService = inject(ConfirmService)private notifier = inject(Notifier)private router = inject(Router)+ private videoOwnershipService = inject(VideoOwnershipService)readonly videoChangeOwnershipModal = viewChild<VideoChangeOwnershipComponent>('videoChangeOwnershipModal')@@ -160,7 +166,7 @@ export class VideoMainInfoComponent implements OnInit, OnDestroy {privacies: VideoPrivacyType[] = []videoEdit: VideoEdit- ownershipRequestSent: string+ pendingOwnershipRequest: VideoChangeOwnershipprivate schedulerInterval: anyprivate updatedSub: Subscription@@ -195,6 +201,7 @@ export class VideoMainInfoComponent implements OnInit, OnDestroy {this.buildLanguages()this.buildPrivacies()+ this.loadOwnershipRequest()this.ngZone.runOutsideAngular(() => {this.schedulerInterval = setInterval(() => this.minScheduledDate = new Date(), 1000 * 60) // Update every minute@@ -505,8 +512,34 @@ export class VideoMainInfoComponent implements OnInit, OnDestroy {this.videoChangeOwnershipModal().show()}- onChangeOwnershipRequest (username: string) {- this.ownershipRequestSent = username+ onChangeOwnershipRequest (ownershipChange: VideoChangeOwnership) {+ this.pendingOwnershipRequest = ownershipChange+ }++ async cancelOwnershipRequest () {+ const message =+ $localize`Are you sure you want to cancel the ownership change request to "${this.pendingOwnershipRequest.nextOwnerAccount.name}"?`+ const res = await this.confirmService.confirm(message, $localize`Cancel request`)+ if (res === false) return++ this.videoOwnershipService.cancel(this.videoEdit.getVideoAttributes().id)+ .subscribe({+ next: () => {+ this.notifier.success($localize`Ownership change request cancelled`)+ this.pendingOwnershipRequest = null+ },++ error: err => this.notifier.handleError(err)+ })+ }++ loadOwnershipRequest () {+ this.videoOwnershipService.listFromVideo(this.videoEdit.getVideoAttributes().id, VideoChangeOwnershipStatus.WAITING)+ .subscribe(({ data }) => {+ if (data.length === 0) return++ this.pendingOwnershipRequest = data[0]+ })}// ---------------------------------------------------------------------------diff --git a/client/src/app/shared/shared-main/video/video-ownership.service.ts b/client/src/app/shared/shared-main/video/video-ownership.service.tsindex b912a0b1c1..e59a579dff 100644--- a/client/src/app/shared/shared-main/video/video-ownership.service.ts+++ b/client/src/app/shared/shared-main/video/video-ownership.service.ts@@ -1,10 +1,16 @@-import { SortMeta } from 'primeng/api'-import { Observable } from 'rxjs'-import { catchError } from 'rxjs/operators'import { HttpClient, HttpParams } from '@angular/common/http'import { Injectable, inject } from '@angular/core'import { RestExtractor, RestPagination, RestService } from '@app/core'-import { ResultList, VideoChangeOwnership, VideoChangeOwnershipAccept, VideoChangeOwnershipCreate } from '@peertube/peertube-models'+import {+ ResultList,+ VideoChangeOwnership,+ VideoChangeOwnershipAccept,+ VideoChangeOwnershipCreate,+ VideoChangeOwnershipStatusType+} from '@peertube/peertube-models'+import { SortMeta } from 'primeng/api'+import { Observable } from 'rxjs'+import { catchError } from 'rxjs/operators'import { environment } from '../../../../environments/environment'@Injectable()@@ -15,7 +21,7 @@ export class VideoOwnershipService {private static BASE_VIDEO_CHANGE_OWNERSHIP_URL = environment.apiUrl + '/api/v1/videos/'- changeOwnership (id: number, username: string) {+ sendChangeRequest (id: number, username: string) {const url = VideoOwnershipService.BASE_VIDEO_CHANGE_OWNERSHIP_URL + id + '/give-ownership'const body: VideoChangeOwnershipCreate = {username@@ -25,7 +31,7 @@ export class VideoOwnershipService {.pipe(catchError(res => this.restExtractor.handleError(res)))}- getOwnershipChanges (pagination: RestPagination, sort: SortMeta): Observable<ResultList<VideoChangeOwnership>> {+ list (pagination: RestPagination, sort: SortMeta): Observable<ResultList<VideoChangeOwnership>> {const url = VideoOwnershipService.BASE_VIDEO_CHANGE_OWNERSHIP_URL + 'ownership'let params = new HttpParams()@@ -35,15 +41,32 @@ export class VideoOwnershipService {.pipe(catchError(res => this.restExtractor.handleError(res)))}- acceptOwnership (id: number, input: VideoChangeOwnershipAccept) {+ listFromVideo (videoId: number, status: VideoChangeOwnershipStatusType): Observable<ResultList<VideoChangeOwnership>> {+ const url = VideoOwnershipService.BASE_VIDEO_CHANGE_OWNERSHIP_URL + videoId + '/ownership'++ let params = new HttpParams()+ params = params.set('status', status)++ return this.authHttp.get<ResultList<VideoChangeOwnership>>(url, { params })+ .pipe(catchError(res => this.restExtractor.handleError(res)))+ }++ accept (id: number, input: VideoChangeOwnershipAccept) {const url = VideoOwnershipService.BASE_VIDEO_CHANGE_OWNERSHIP_URL + 'ownership/' + id + '/accept'return this.authHttp.post(url, input).pipe(catchError(err => this.restExtractor.handleError(err)))}- refuseOwnership (id: number) {+ refuse (id: number) {const url = VideoOwnershipService.BASE_VIDEO_CHANGE_OWNERSHIP_URL + 'ownership/' + id + '/refuse'return this.authHttp.post(url, {}).pipe(catchError(err => this.restExtractor.handleError(err)))}++ cancel (id: number) {+ const url = VideoOwnershipService.BASE_VIDEO_CHANGE_OWNERSHIP_URL + 'ownership/' + id++ return this.authHttp.delete(url)+ .pipe(catchError(err => this.restExtractor.handleError(err)))+ }}diff --git a/packages/models/src/videos/channel/video-channel-activity.model.ts b/packages/models/src/videos/channel/video-channel-activity.model.tsindex b147e101a0..09e409a2f8 100644--- a/packages/models/src/videos/channel/video-channel-activity.model.ts+++ b/packages/models/src/videos/channel/video-channel-activity.model.ts@@ -15,7 +15,8 @@ export const VideoChannelActivityAction = {SEND_OWNERSHIP_REQUEST: 12,ACCEPT_OWNERSHIP_REQUEST: 13,REFUSE_OWNERSHIP_REQUEST: 14,- UPDATE_EMBED_POLICY: 15+ UPDATE_EMBED_POLICY: 15,+ DELETE_OWNERSHIP_REQUEST: 16} as constexport type VideoChannelActivityActionType = typeof VideoChannelActivityAction[keyof typeof VideoChannelActivityAction]diff --git a/packages/server-commands/src/videos/change-ownership-command.ts b/packages/server-commands/src/videos/change-ownership-command.tsindex bc70994bc6..1aaad2b828 100644--- a/packages/server-commands/src/videos/change-ownership-command.ts+++ b/packages/server-commands/src/videos/change-ownership-command.ts@@ -88,4 +88,21 @@ export class ChangeOwnershipCommand extends AbstractCommand {defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204})}++ delete (+ options: OverrideCommandOptions & {+ ownershipId: number+ }+ ) {+ const { ownershipId } = options+ const path = '/api/v1/videos/ownership/' + ownershipId++ return this.deleteRequest({+ ...options,++ path,+ implicitToken: true,+ defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204+ })+ }}diff --git a/packages/tests/src/api/check-params/video-change-ownership.ts b/packages/tests/src/api/check-params/video-change-ownership.tsindex 320be6fe18..18d98b97fe 100644--- a/packages/tests/src/api/check-params/video-change-ownership.ts+++ b/packages/tests/src/api/check-params/video-change-ownership.ts@@ -267,6 +267,73 @@ describe('Test video change ownership API validator', function () {})})+ describe('Delete ownership change request', function () {+ let deleteOwnershipChangeId: number+ let videoId: string++ before(async function () {+ const { uuid } = await server.videos.quickUpload({ name: 'video', token: userToken })+ videoId = uuid++ await server.changeOwnership.create({ videoId, username: 'another_user', token: userToken })++ const { data } = await server.changeOwnership.listOfVideo({ videoId })+ deleteOwnershipChangeId = data[0].id+ })++ it('Should fail if not authenticated', async function () {+ await server.changeOwnership.delete({+ ownershipId: deleteOwnershipChangeId,+ token: null,+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401+ })+ })++ it('Should fail with a non existing ownership id', async function () {+ await server.changeOwnership.delete({ ownershipId: 42, expectedStatus: HttpStatusCode.NOT_FOUND_404 })+ })++ it('Should fail with a video from another user', async function () {+ await server.changeOwnership.delete({+ ownershipId: deleteOwnershipChangeId,+ token: anotherUserToken,+ expectedStatus: HttpStatusCode.FORBIDDEN_403+ })+ })++ it('Should succeed with valid params', async function () {+ await server.changeOwnership.delete({+ token: userEditorToken,+ ownershipId: deleteOwnershipChangeId+ })+ })++ it('Should fail to delete a non existing request', async function () {+ await server.changeOwnership.delete({+ ownershipId: deleteOwnershipChangeId,+ expectedStatus: HttpStatusCode.NOT_FOUND_404+ })+ })++ it('Should fail with a non pending request', async function () {+ await server.changeOwnership.create({ videoId, username: 'another_user', token: userToken })++ const { data } = await server.changeOwnership.listOfVideo({ videoId })+ const newOwnershipChangeId = data[0].id++ await server.changeOwnership.accept({+ ownershipId: newOwnershipChangeId,+ token: anotherUserToken,+ channelId: await server.channels.getDefaultId({ token: anotherUserToken })+ })++ await server.changeOwnership.delete({+ ownershipId: newOwnershipChangeId,+ expectedStatus: HttpStatusCode.BAD_REQUEST_400+ })+ })+ })+after(async function () {await cleanupTests([ server ])})diff --git a/packages/tests/src/api/videos/channel-activities.ts b/packages/tests/src/api/videos/channel-activities.tsindex 0d76c9dc3f..322ab1ae31 100644--- a/packages/tests/src/api/videos/channel-activities.ts+++ b/packages/tests/src/api/videos/channel-activities.ts@@ -834,6 +834,22 @@ describe('Test channel activities', function () {expect(a.video.name).to.equal('video for ownership change')expect(a.targetAccount.username).to.equal('user_ownership_change')})++ it('Should delete an ownership request', async function () {+ await server.changeOwnership.create({ videoId: video.id, username: 'user_ownership_change' })+ const { data } = await server.changeOwnership.listOfVideo({ videoId: video.id })+ const changeOwnershipId = data[0].id++ const a = await getActivityAfterAction(async () => {+ await server.changeOwnership.delete({ ownershipId: changeOwnershipId })+ })++ expect(a.action.id).to.equal(VideoChannelActivityAction.DELETE_OWNERSHIP_REQUEST)+ expect(a.targetType.id).to.equal(VideoChannelActivityTarget.VIDEO)+ expect(a.account.name).to.equal('root')+ expect(a.video.name).to.equal('video for ownership change')+ expect(a.targetAccount.username).to.equal('user_ownership_change')+ })})describe('Common', function () {diff --git a/packages/tests/src/api/videos/video-change-ownership.ts b/packages/tests/src/api/videos/video-change-ownership.tsindex 94d2cb5430..8e0c5adc86 100644--- a/packages/tests/src/api/videos/video-change-ownership.ts+++ b/packages/tests/src/api/videos/video-change-ownership.ts@@ -1,6 +1,6 @@/* oxlint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */-import { HttpStatusCode, VideoPrivacy } from '@peertube/peertube-models'+import { HttpStatusCode, VideoChangeOwnershipStatus, VideoPrivacy } from '@peertube/peertube-models'import {ChangeOwnershipCommand,cleanupTests,@@ -212,7 +212,21 @@ describe('Test video change ownership - nominal', function () {lastRequestId = body.data[0].id})+ it('Should delete an ownership change request', async function () {+ const { data } = await command.listOfVideo({ videoId: liveId })+ const ownershipChangeId = data[0].id++ await command.delete({ ownershipId: ownershipChangeId, token: firstUserToken })++ const bodyAfterDelete = await command.listOfVideo({ videoId: liveId, state: VideoChangeOwnershipStatus.WAITING })+ expect(bodyAfterDelete.total).to.equal(0)+ })+it('Should accept a live ownership change', async function () {+ await command.create({ token: firstUserToken, videoId: liveId, username: secondUser })+ const body = await command.list({ token: secondUserToken })+ lastRequestId = body.data[0].id+await command.accept({ token: secondUserToken, ownershipId: lastRequestId, channelId: secondUserChannelId })await waitJobs(servers)diff --git a/server/core/controllers/api/videos/ownership.ts b/server/core/controllers/api/videos/ownership.tsindex 00d4739818..a5780cca75 100644--- a/server/core/controllers/api/videos/ownership.ts+++ b/server/core/controllers/api/videos/ownership.ts@@ -16,6 +16,7 @@ import {setDefaultPagination,videosAcceptChangeOwnershipValidator,videosChangeOwnershipValidator,+ videosDeleteChangeOwnershipValidator,videosListVideoOwnershipChangesValidator,videosTerminateChangeOwnershipValidator} from '../../../middlewares/index.js'@@ -64,6 +65,13 @@ ownershipVideoRouter.post(asyncRetryTransactionMiddleware(refuseOwnership))+ownershipVideoRouter.delete(+ '/ownership/:id',+ authenticate,+ asyncMiddleware(videosDeleteChangeOwnershipValidator),+ asyncRetryTransactionMiddleware(deleteOwnership)+)+// ---------------------------------------------------------------------------export {@@ -196,3 +204,25 @@ function refuseOwnership (req: express.Request, res: express.Response) {return res.sendStatus(HttpStatusCode.NO_CONTENT_204)})}++function deleteOwnership (req: express.Request, res: express.Response) {+ return sequelizeTypescript.transaction(async t => {+ const videoChangeOwnership = res.locals.videoChangeOwnership+ const channel = await VideoChannelModel.loadAndPopulateAccount(videoChangeOwnership.Video.channelId, t)++ await videoChangeOwnership.destroy({ transaction: t })++ await VideoChannelActivityModel.addVideoOwnershipChangeActivity({+ action: VideoChannelActivityAction.DELETE_OWNERSHIP_REQUEST,+ user: res.locals.oauth.token.User,+ channel,+ video: videoChangeOwnership.Video,+ targetAccount: videoChangeOwnership.NextOwner,+ transaction: t+ })++ logger.info('Ownership change request %d deleted.', videoChangeOwnership.id)++ return res.sendStatus(HttpStatusCode.NO_CONTENT_204)+ })+}diff --git a/server/core/initializers/constants.ts b/server/core/initializers/constants.tsindex d187d23a77..422f32bd21 100644--- a/server/core/initializers/constants.ts+++ b/server/core/initializers/constants.ts@@ -741,7 +741,8 @@ export const VIDEO_CHANNEL_ACTIVITY_ACTIONS: { [id in VideoChannelActivityAction[VideoChannelActivityAction.SEND_OWNERSHIP_REQUEST]: 'Send ownership request',[VideoChannelActivityAction.ACCEPT_OWNERSHIP_REQUEST]: 'Accept ownership request',[VideoChannelActivityAction.REFUSE_OWNERSHIP_REQUEST]: 'Refuse ownership request',- [VideoChannelActivityAction.UPDATE_EMBED_POLICY]: 'Update embed policy'+ [VideoChannelActivityAction.UPDATE_EMBED_POLICY]: 'Update embed policy',+ [VideoChannelActivityAction.DELETE_OWNERSHIP_REQUEST]: 'Delete ownership request'}export const VIDEO_CHANNEL_ACTIVITY_TARGETS: { [id in VideoChannelActivityTargetType]: string } = {diff --git a/server/core/middlewares/validators/videos/video-ownership-changes.ts b/server/core/middlewares/validators/videos/video-ownership-changes.tsindex d5f6fd2071..de1edd5293 100644--- a/server/core/middlewares/validators/videos/video-ownership-changes.ts+++ b/server/core/middlewares/validators/videos/video-ownership-changes.ts@@ -139,6 +139,42 @@ export const videosListVideoOwnershipChangesValidator = [}]+export const videosDeleteChangeOwnershipValidator = [+ param('id')+ .custom(isIdValid),++ async (req: express.Request, res: express.Response, next: express.NextFunction) => {+ if (areValidationErrors(req, res)) return+ if (!await doesChangeVideoOwnershipExist(req.params.id, req, res)) return++ const videoChangeOwnership = res.locals.videoChangeOwnership++ if (videoChangeOwnership.status !== VideoChangeOwnershipStatus.WAITING) {+ res.fail({+ status: HttpStatusCode.BAD_REQUEST_400,+ message: req.t('Ownership already accepted or refused')+ })+ return+ }++ const video = await VideoModel.loadWithRights(videoChangeOwnership.Video.id)++ if (+ !await checkCanManageVideo({+ user: res.locals.oauth.token.User,+ video,+ right: UserRight.CHANGE_VIDEO_OWNERSHIP,+ checkIsOwner: false,+ checkIsLocal: true,+ req,+ res+ })+ ) return++ return next()+ }+]+// ---------------------------------------------------------------------------// Private// ---------------------------------------------------------------------------diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yamlindex 9ab95929e6..74f1b120e5 100644--- a/support/doc/api/openapi.yaml+++ b/support/doc/api/openapi.yaml@@ -3022,6 +3022,24 @@ paths:'404':description: video ownership change not found+ '/api/v1/videos/ownership/{id}':+ delete:+ summary: Delete ownership change request+ description: Delete an ownership change request. Only users who can manage the video can delete the request.+ tags:+ - Video Ownership Change+ security:+ - OAuth2: []+ parameters:+ - $ref: '#/components/parameters/idOrUUID'+ responses:+ '204':+ description: successful operation+ '403':+ description: only users who can manage the video can delete an ownership change request+ '404':+ description: video ownership change not found+'/api/v1/videos/{id}/ownership':get:summary: List ownership change requests for a video