Commit 65d24603 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Reject notifications in uninitialized NotificationSubscriber

Wait until client identify itself before sending it notifications.
parent 4a3d8d20
......@@ -39,6 +39,7 @@ public:
TestableNotificationSubscriber()
: NotificationSubscriber()
{
mSubscriber = "TestSubscriber";
}
void setAllMonitored(bool allMonitored)
......
......@@ -140,7 +140,7 @@ void NotificationSubscriber::disconnectSubscriber()
void NotificationSubscriber::registerSubscriber(const Protocol::CreateSubscriptionCommand &command)
{
qDebug() << "Subscriber identified:" << command.subscriberName();
qDebug() << "Subscriber" << this << "identified as" << command.subscriberName();
mSubscriber = command.subscriberName();
if (mManager) {
......@@ -307,6 +307,7 @@ bool NotificationSubscriber::isMoveDestinationResourceMonitored(const Protocol::
return mMonitoredResources.contains(msg.destinationResource());
}
bool NotificationSubscriber::acceptsItemNotification(const Protocol::ItemChangeNotification &notification) const
{
if (notification.items().count() == 0) {
......@@ -514,6 +515,11 @@ bool NotificationSubscriber::acceptsSubscriptionNotification(const Protocol::Sub
bool NotificationSubscriber::acceptsNotification(const Protocol::ChangeNotification &notification) const
{
// Uninitialized subscriber gets nothing
if (mSubscriber.isEmpty()) {
return false;
}
// session is ignored
if (mIgnoredSessions.contains(notification.sessionId())) {
return false;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment