mirror of https://github.com/nymea/nymea.git
add a hack for meeting the zapf deadline
disable having a device per phone endpoint. instead just register a single device and broadcast stuff to /everyone until the cloud and app are updated for thispull/135/head
parent
6334496c8c
commit
aede5f2afa
|
|
@ -267,7 +267,9 @@ int AWSConnector::sendPushNotification(const QString &userId, const QString &end
|
|||
params.insert("title", title);
|
||||
params.insert("body", text);
|
||||
params.insert("timestamp", QDateTime::currentMSecsSinceEpoch());
|
||||
publish(QString("%1/notify/user/%2/%3").arg(m_clientId, userId, endpointId), params);
|
||||
// publish(QString("%1/notify/user/%2/%3").arg(m_clientId, userId, endpointId), params);
|
||||
Q_UNUSED(userId)
|
||||
publish(QString("%1/notify/user/%2").arg(m_clientId, endpointId), params);
|
||||
return m_transactionId;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,12 @@ ParamTypeId notifyActionParamBodyId = ParamTypeId("4bd0fa87-c663-4621-8040-99b6d
|
|||
|
||||
StateTypeId connectedStateTypeId = StateTypeId("518e27b6-c3bf-49d7-be24-05ae978c00f7");
|
||||
|
||||
// FIXME: This ZAPF_HOTFIX is here to disable some features in order to meet the ZAPF deadline
|
||||
// Once the cloud infrastructure is fixed to properly give out unique and persistent ids
|
||||
// for push notification enabled devices, remove this complete commit (apply -r)
|
||||
// It should remove all the ZAPF_HOTFIX parts in here and one line in awsconnector.cpp
|
||||
#define ZAPF_HOTFIX 1
|
||||
|
||||
CloudNotifications::CloudNotifications(AWSConnector* awsConnector, QObject *parent):
|
||||
DevicePlugin(parent),
|
||||
m_awsConnector(awsConnector)
|
||||
|
|
@ -157,6 +163,27 @@ DeviceManager::DeviceError CloudNotifications::executeAction(Device *device, con
|
|||
void CloudNotifications::pushNotificationEndpointsUpdated(const QList<AWSConnector::PushNotificationsEndpoint> &endpoints)
|
||||
{
|
||||
qCDebug(dcCloud()) << "Push Notification endpoint update";
|
||||
#if ZAPF_HOTFIX
|
||||
if (endpoints.isEmpty() && myDevices().count() > 0) {
|
||||
emit autoDeviceDisappeared(myDevices().first()->id());
|
||||
return;
|
||||
}
|
||||
|
||||
if (myDevices().count() > 0) {
|
||||
// already have a device, ignore it
|
||||
return;
|
||||
}
|
||||
|
||||
DeviceDescriptor descriptor(cloudNotificationsDeviceClassId, "Push notifications", "");
|
||||
ParamList params;
|
||||
Param userIdParam(cloudNotificationsDeviceClassUserParamId, ""); // Not used for now
|
||||
params.append(userIdParam);
|
||||
Param endpointIdParam(cloudNotificationsDeviceClassEndpointParamId, "everyone");
|
||||
params.append(endpointIdParam);
|
||||
descriptor.setParams(params);
|
||||
emit autoDevicesAppeared(cloudNotificationsDeviceClassId, {descriptor});
|
||||
|
||||
#else
|
||||
QList<Device*> devicesToRemove;
|
||||
foreach (Device *configuredDevice, myDevices()) {
|
||||
bool found = false;
|
||||
|
|
@ -198,11 +225,14 @@ void CloudNotifications::pushNotificationEndpointsUpdated(const QList<AWSConnect
|
|||
}
|
||||
}
|
||||
emit autoDevicesAppeared(cloudNotificationsDeviceClassId, devicesToAdd);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void CloudNotifications::pushNotificationEndpointAdded(const AWSConnector::PushNotificationsEndpoint &endpoint)
|
||||
{
|
||||
#if ZAPF_HOTFIX
|
||||
pushNotificationEndpointsUpdated({endpoint});
|
||||
#else
|
||||
DeviceDescriptor descriptor(cloudNotificationsDeviceClassId, endpoint.displayName, QString("Send notifications to %1").arg(endpoint.displayName));
|
||||
ParamList params;
|
||||
Param userIdParam(cloudNotificationsDeviceClassUserParamId, endpoint.userId);
|
||||
|
|
@ -211,6 +241,7 @@ void CloudNotifications::pushNotificationEndpointAdded(const AWSConnector::PushN
|
|||
params.append(endpointIdParam);
|
||||
descriptor.setParams(params);
|
||||
emit autoDevicesAppeared(cloudNotificationsDeviceClassId, {descriptor});
|
||||
#endif
|
||||
}
|
||||
|
||||
void CloudNotifications::pushNotificationSent(int id, int status)
|
||||
|
|
|
|||
Loading…
Reference in New Issue