Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to change ownership of a video #510

Closed
22decembre opened this issue Apr 15, 2018 · 11 comments
Closed

Add ability to change ownership of a video #510

22decembre opened this issue Apr 15, 2018 · 11 comments

Comments

@22decembre
Copy link

It would be cool if the admin of the instance and/or the owner of a video can «give it» to another user.

@gegeweb
Copy link
Contributor

gegeweb commented Jul 28, 2018

Hi,

Before this feature is implemented, there is a way to modify the video owner?
I would like to change the owner for the first videos uploaded on my instance.
I'm now on 1.0.0-beta.10.pre.2.

@rigelk
Copy link
Collaborator

rigelk commented Jul 28, 2018

@gegeweb no, there is no way to do that at the moment.

@grizio
Copy link
Contributor

grizio commented Jul 28, 2018

I tried to implement the feature. I stopped because there is lot of things to handle and some architectural decisions to be made.

Here a simple design of the feature:

diagram of the process

For each lane, it could have ActivityPub in the middle. So some questions arise:

  • Should we accept to give the ownership through multiple instances?
  • How to chose the user to give the video?
  • How to handle cases when the video is removed from first server and some users watch it?
PlantUML code of diagram
@startuml
|Current owner|
start
:Send invitation;

|Next owner|
if (accepts) then (no)
  |Next owner|
  :Send refusal;
  |Current owner|
  :Save refusal;

  stop

else (yes)
  |Next owner|
  :Choose channel;
  :Send acceptation;

  |Current owner|
  :Send video file;

  |Next owner|
  :Save video file;
  :Publish (or not?);

  |Current owner|
  :Remove video file locally;

  stop

endif
@enduml

@rigelk
Copy link
Collaborator

rigelk commented Jul 28, 2018

@grizio ah indeed, I didn't notice you had already begun working on the issue. I'm marking it as already in progress then.

To answer your questions, I think - but @Chocobozzz might want to interject - that we should clearly define the scope:

  • for now the model imposes a unique owner (for now). so giving the ownership effectively means transferring data and rights. as to wether this should only be local, I don't see why, but it sure would be simpler…
  • giving the handle of that user should be enough.
  • when the video is removed from the first server, doing a redirection (302) to the new server.

@gegeweb
Copy link
Contributor

gegeweb commented Jul 29, 2018

For me there are two needs.

The first, allow on the Peertube instance to locally modify the author of the video by the admin. For example, when starting the Peertube instance, the administrator publishes some videos under the root account. After creating his user account then he would like to be able to transfer the first videos to the user account. ;)

And the second to allow to transfer the video to a user on another instance.

Perhaps the first is less complex to implement? I was wondering if we could do it at the DB level directly and after, update the video on the web UI to broadcast the change.
An administrator already has the right to edit a video even if he is not the author. In theory, it shouldn't be complicated (I haven't looked at the code and structure of the DB) to transfer to one of the users of the instance.

@grizio
Copy link
Contributor

grizio commented Jul 29, 2018

Yes, this could be split in two different features. I will simply start at local instance level.

However, about the change of ownership, it is not trivial, even it is pretty simple. The above schema is still valid minus the sending of the video.

The acceptance by the target user has several reasons:

  • Avoid a user sending video to anyone and give all responsibilities (quota, respect of terms…) to them
  • Let the user chose the channel to put the video in (and maybe create a new one beforehand)

But if the admin should have all rights, another feature could be created so he can send directly to the user channel.

I continue with this scenario. If you do not agree, do not hesitate to answer.

Chocobozzz pushed a commit that referenced this issue Sep 4, 2018
* [#510] Create a new route to get the list of user names

To be able to transfer ownership to a user,
we need to be able to select him from the list of users.

Because the list could be too big, we add a autocomplete feature.

This commit does the following:

* Add a API endpoint to get a list of user names by searching its name

* [#510] The user can choose the next owner of the video

To be able to transfer ownership to a user,
we need the owner to be able to select the user.

The server can autocomplete the name of the user to give the ownership.
We add a dialog for the user to actually select it.

This commit does the following:

* Create a modal for the owner to select the next one
* Opens this modal with a button into the menu *more*
* Make the dependency injection

* [#510] When the user choose the next owner, create a request in database

For the change of ownership to happen, we need to store the temporary requests.
When the user make the request, save it to database.

This commit does the following:

* Create the model to persist change ownership requests
* Add an API to manage ownership operations
* Add a route to persist an ownership request

* [#510] A user can fetch its ownership requests sent to him

To be able to accept or refuse a change of ownership,
the user must be able to fetch them.

This commit does the following:

* Add an API to list ownership for a user
* Add the query to database model

* [#510] A user can validate an ownership requests sent to him - server

The user can accept or refuse any ownership request that was sent to him.
This commit focus only on the server part.

This commit does the following:

* Add an API for the user to accept or refuse a video ownership
* Add validators to ensure security access
* Add a query to load a specific video change ownership request

* [#510] A user can validate an ownership requests sent to him - web

The user can accept or refuse any ownership request that was sent to him.
This commit focus only on the web part.

This commit does the following:

* Add a page to list user ownership changes
* Add actions to accept or refuse them
* When accepting, show a modal requiring the channel to send the video

* Correct lint - to squash

* [#510] PR reviews - to squash

This commit does the following:

* Search parameter for user autocompletion is required from middleware directly

* [#510] PR reviews - to squash with creation in database commit

This commit does the following:

* Add the status attribute in model
* Set this attribute on instance creation
* Use AccountModel method `loadLocalByName`

* [#510] PR reviews - to squash with fetch ownership

This commit does the following:

* Add the scope `FULL` for database queries with includes
* Add classic pagination middlewares

* [#510] PR reviews - to squash with ownership validation - server

This commit does the following:

* Add a middleware to validate whether a user can validate an ownership
* Change the ownership status instead of deleting the row

* [#510] PR reviews - to squash with ownership validation - client

This commit does the following:

* Correct indentation of html files with two-spaces indentation
* Use event emitter instead of function for accept event
* Update the sort of ownership change table for a decreasing order by creation date
* Add the status in ownership change table
* Use classic method syntax

* code style - to squash

* Add new user right - to squash

* Move the change to my-account instead of video-watch - to squash

As requested in pull-request, move the action to change ownership into my videos page.

The rest of the logic was not really changed.

This commit does the following:

- Move the modal into my video page
- Create the generic component `button` to keep some styles and logic

* [#510] Add tests for the new feature

To avoid regression, we add tests for all api of ownership change.

This commit does the following:

- Create an end-to-end test for ownership change
- Divide it to one test per request

* [#510] Do not send twice the same request to avoid spam

We can send several time the same request to change ownership.
However, it will spam the user.
To avoid this, we do not save a request already existing in database.

This commit does the following:

- Check whether the request exist in database
- Add tests to verify this new condition

* [#510] Change icons

Change icons so they remains logic with the rest of the application.

This commit does the following:

- Add svg for missing icons
- Add icons in `my-button` component
- Use these new icons

* [#510] Add control about the user quota

The user should be able to accept a new video only if his quota allows it.

This commit does the following:

- Update the middleware to control the quota
- Add tests verifying the control

* Correct merge

- Use new modal system
- Move button to new directory `buttons`

* PR reviews - to squash
@Chocobozzz
Copy link
Owner

Implemented by @grizio in 74d6346

@MathiasRenner
Copy link

Thank for this nice feature! Will the view count stay the same after you changed the ownership of a video?

@rigelk
Copy link
Collaborator

rigelk commented Apr 19, 2020

@MathiasRenner yes.

@MathiasRenner
Copy link

@rigelk Super nice, thanks! And will the link/URL to the video stay the same after having changed ownership?

@JohnXLivingston
Copy link
Contributor

@rigelk Super nice, thanks! And will the link/URL to the video stay the same after having changed ownership?

Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants