Filter out content in sync that is currently unhandled (#198)
I had a look at sync.cpp and checked which parts of the sync response are currently handled and which not. As I think it is unnecessary to let the unhandled data be transmitted without being handled I added these filters. In the same term I increased the timeout server-side to 30s as Riot defaults to this value as well. Especially now when a lots of presence-updates are not send anymore this value is more relevant. It is now also possible to use a filter that is defined in`client/sync_filter`. Advanced users might want to set an own filter here. [ci skip]
This commit is contained in:
parent
82341247f7
commit
0570135253
@ -159,4 +159,7 @@ private:
|
||||
|
||||
// Token to be used for the next sync.
|
||||
QString next_batch_;
|
||||
|
||||
// filter to be send as filter-param for (initial) /sync requests
|
||||
QString filter_;
|
||||
};
|
||||
|
@ -41,6 +41,32 @@ MatrixClient::MatrixClient(QString server, QObject *parent)
|
||||
QSettings settings;
|
||||
txn_id_ = settings.value("client/transaction_id", 1).toInt();
|
||||
|
||||
QJsonObject default_filter{
|
||||
{"room",
|
||||
QJsonObject{
|
||||
{"include_leave", true},
|
||||
{"account_data",
|
||||
QJsonObject{
|
||||
{"not_types", QJsonArray{"*"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},{"account_data",
|
||||
QJsonObject{
|
||||
{"not_types", QJsonArray{"*"}},
|
||||
},
|
||||
},{"presence",
|
||||
QJsonObject{
|
||||
{"not_types", QJsonArray{"*"}},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
filter_ = settings.value(
|
||||
"client/sync_filter",
|
||||
QJsonDocument(default_filter).toJson(QJsonDocument::Compact)
|
||||
).toString();
|
||||
|
||||
connect(this,
|
||||
&QNetworkAccessManager::networkAccessibleChanged,
|
||||
this,
|
||||
@ -194,17 +220,10 @@ MatrixClient::registerUser(const QString &user, const QString &pass, const QStri
|
||||
void
|
||||
MatrixClient::sync() noexcept
|
||||
{
|
||||
QJsonObject filter{
|
||||
{"room",
|
||||
QJsonObject{
|
||||
{"include_leave", true},
|
||||
}},
|
||||
};
|
||||
|
||||
QUrlQuery query;
|
||||
query.addQueryItem("set_presence", "online");
|
||||
query.addQueryItem("filter", QJsonDocument(filter).toJson(QJsonDocument::Compact));
|
||||
query.addQueryItem("timeout", "15000");
|
||||
query.addQueryItem("filter", filter_);
|
||||
query.addQueryItem("timeout", "30000");
|
||||
query.addQueryItem("access_token", token_);
|
||||
|
||||
if (next_batch_.isEmpty()) {
|
||||
@ -334,6 +353,7 @@ MatrixClient::initialSync() noexcept
|
||||
{
|
||||
QUrlQuery query;
|
||||
query.addQueryItem("timeout", "0");
|
||||
query.addQueryItem("filter", filter_);
|
||||
query.addQueryItem("access_token", token_);
|
||||
|
||||
QUrl endpoint(server_);
|
||||
|
Loading…
Reference in New Issue
Block a user