diff --git a/qutebrowser/misc/pastebin.py b/qutebrowser/misc/pastebin.py index 0f2ed8ce4..f317670ec 100644 --- a/qutebrowser/misc/pastebin.py +++ b/qutebrowser/misc/pastebin.py @@ -60,7 +60,7 @@ class PastebinClient(QObject): self._client = client self._api_url = api_url - def paste(self, name, title, text, parent=None): + def paste(self, name, title, text, parent=None, private=False): """Paste the text into a pastebin and return the URL. Args: @@ -68,6 +68,7 @@ class PastebinClient(QObject): title: The post title. text: The text to post. parent: The parent paste to reply to. + private: Whether to paste privately. """ data = { 'text': text, @@ -77,6 +78,9 @@ class PastebinClient(QObject): } if parent is not None: data['reply'] = parent + if private: + data['private'] = '1' + url = QUrl(urllib.parse.urljoin(self._api_url, 'create')) self._client.post(url, data) diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py index 71e33886f..d77194075 100644 --- a/qutebrowser/utils/version.py +++ b/qutebrowser/utils/version.py @@ -486,4 +486,5 @@ def pastebin_version(pbclient=None): pbclient.paste(getpass.getuser(), "qute version info {}".format(qutebrowser.__version__), - version()) + version(), + private=True) diff --git a/tests/unit/misc/test_pastebin.py b/tests/unit/misc/test_pastebin.py index 1d684dc4e..cbd6f4c3e 100644 --- a/tests/unit/misc/test_pastebin.py +++ b/tests/unit/misc/test_pastebin.py @@ -79,6 +79,20 @@ def test_paste_without_parent(data, pbclient): assert http_stub.url == QUrl('https://crashes.qutebrowser.org/api/create') +def test_paste_private(pbclient): + data = { + "name": "the name", + "title": "the title", + "text": "some Text", + "apikey": "ihatespam", + "private": "1", + } + http_stub = pbclient._client + pbclient.paste(data["name"], data["title"], data["text"], private=True) + assert pbclient._client.data == data + assert http_stub.url == QUrl('https://crashes.qutebrowser.org/api/create') + + @pytest.mark.parametrize('http', [ "http://paste.the-compiler.org/view/ges83nt3", "http://paste.the-compiler.org/view/3gjnwg4"