mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 13:23:34 -07:00
add setComment API endpoint
This commit is contained in:
parent
bb1c02125b
commit
a3eb27a04d
5 changed files with 25 additions and 0 deletions
|
@ -144,6 +144,7 @@ namespace BitTorrent
|
|||
virtual QDateTime creationDate() const = 0;
|
||||
virtual QString creator() const = 0;
|
||||
virtual QString comment() const = 0;
|
||||
virtual void setComment(const QString &comment) = 0;
|
||||
virtual bool isPrivate() const = 0;
|
||||
virtual qlonglong totalSize() const = 0;
|
||||
virtual qlonglong wantedSize() const = 0;
|
||||
|
|
|
@ -2959,3 +2959,8 @@ QFuture<std::invoke_result_t<Func>> TorrentImpl::invokeAsync(Func &&func) const
|
|||
|
||||
return future;
|
||||
}
|
||||
|
||||
void TorrentImpl::setComment(const QString &comment)
|
||||
{
|
||||
m_comment = comment;
|
||||
}
|
||||
|
|
|
@ -106,6 +106,7 @@ namespace BitTorrent
|
|||
QDateTime creationDate() const override;
|
||||
QString creator() const override;
|
||||
QString comment() const override;
|
||||
void setComment(const QString &comment) override;
|
||||
bool isPrivate() const override;
|
||||
qlonglong totalSize() const override;
|
||||
qlonglong wantedSize() const override;
|
||||
|
|
|
@ -2143,3 +2143,20 @@ void TorrentsController::onMetadataDownloaded(const BitTorrent::TorrentInfo &inf
|
|||
iter.value().setTorrentInfo(info);
|
||||
}
|
||||
}
|
||||
|
||||
void TorrentsController::setCommentAction()
|
||||
{
|
||||
requireParams({u"hash"_s, u"comment"_s});
|
||||
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_s]);
|
||||
QString comment = params()[u"comment"_s].trimmed();
|
||||
|
||||
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->getTorrent(id);
|
||||
if (!torrent)
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
|
||||
comment.replace(QRegularExpression(u"\r?\n|\r"_s), u" "_s);
|
||||
torrent->setComment(comment);
|
||||
|
||||
setResult(QString());
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ private slots:
|
|||
void recheckAction();
|
||||
void reannounceAction();
|
||||
void renameAction();
|
||||
void setCommentAction();
|
||||
void setCategoryAction();
|
||||
void createCategoryAction();
|
||||
void editCategoryAction();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue