Video Privacy Manager API - Error after removing scopes - Plugin

I wrote a simple plugin that uses video-privacy-manager-api to just keep unlisted as privacy scope for videos.

https://docs.joinpeertube.org/api-plugins?id=video-privacy-manager-api

It removes private , public and internal.

$ cat ~/peertube-plugin-mytest/main.js
 
async function register ({
  registerHook,
  registerSetting,
  videoPrivacyManager,
  playlistPrivacyManager
}) {
  videoPrivacyManager.deletePrivacy(1)
  videoPrivacyManager.deletePrivacy(3)
  videoPrivacyManager.deletePrivacy(4)
  playlistPrivacyManager.deletePlaylistPrivacy(1)
  playlistPrivacyManager.deletePlaylistPrivacy(3)
}

async function unregister () {
  return
}

module.exports = {
  register,
  unregister
}

Installation is ok, no errors.

But when I tried to create a video from interface with publish, I got:

[localhost:9000] 2021-07-06 20:43:47.668 warn: Incorrect request parameters {
  "path": "/api/v1/videos/upload-resumable",
  "err": {
    "privacy": {
      "value": "3",
      "msg": "Should have correct video privacy",
      "param": "privacy",
      "location": "body"
    }
  }
}

It is trying to send 3 and it fails.

[localhost:9000] 2021-07-06 20:43:47.667 debug: Checking videosAddResumableInitValidator parameters and headers {
  "parameters": {
    "name": "file_example_MP4_480_1_5MG.mp4",
    "mimeType": "video/mp4",
    "size": "1570024",
    "lastModified": "1625521762818",
    "waitTranscoding": true,
    "commentsEnabled": true,
    "downloadEnabled": true,
    "channelId": 1,
    "nsfw": false,
    "privacy": "3",
    "filename": "file_example_MP4_480_1_5MG.mp4"
  },
  "headers": {
    "host": "localhost:9000",
    "connection": "keep-alive",
    "content-length": "1210",
    "pragma": "no-cache",
    "cache-control": "no-cache",
    "sec-ch-ua": "\" Not;A Brand\";v=\"99\", \"Google Chrome\";v=\"91\", \"Chromium\";v=\"91\"",
    "sec-ch-ua-mobile": "?0",
    "authorization": "Bearer 8b95499c17e1959338e6cf5c221cb8185930007c",
    "content-type": "multipart/form-data; boundary=----WebKitFormBoundaryqDBDCrWFyFDMMB9h",
    "accept": "application/json",
    "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36",
    "x-upload-content-length": "1570024",
    "x-upload-content-type": "video/mp4",
    "origin": "http://localhost:9000",
    "sec-fetch-site": "same-origin",
    "sec-fetch-mode": "cors",
    "sec-fetch-dest": "empty",
    "referer": "http://localhost:9000/videos/upload",
    "accept-encoding": "gzip, deflate, br",
    "accept-language": "en-US,en;q=0.9"
  },
  "files": {}
}
[localhost:9000] 2021-07-06 20:43:47.668 warn: Incorrect request parameters {
  "path": "/api/v1/videos/upload-resumable",
  "err": {
    "privacy": {
      "value": "3",
      "msg": "Should have correct video privacy",
      "param": "privacy",
      "location": "body"
    }
  }
}

Also the api returns the default privacies as expected, it removes all the rest successfully.

http://localhost:9000/api/v1/videos/privacies

Response:

{"2":"Unlisted"}

I found that the ListBox from ComboBox on pivacy is partially broken too.

It should show Unlisted.

Hi,

It’s a bug that is fixed in 3.3.rc-1 Seems not? Deleting privacy options breaks video uploading · Issue #4159 · Chocobozzz/PeerTube · GitHub Will investigate

Thank you @Chocobozzz. I appreciate it. Please let me know if you find a fix for the bug.

The original issue was solved along with other related ones.
Ref: Deleting privacy options breaks video uploading · Issue #4159 · Chocobozzz/PeerTube · GitHub