Skip to content

Commit

Permalink
Bluetooth & location newsfeed (#139)
Browse files Browse the repository at this point in the history
* Send newsfeed for bluetooth

* Send newsfeed for location

* Fix Wi-Fi newsfeed title and content

* Update notification collection on Postman
  • Loading branch information
OfirMatasas authored Sep 15, 2023
1 parent e0a5225 commit 4c511a6
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Notification",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "26136776",
"_collection_link": "https://warped-shadow-814178.postman.co/workspace/My-Workspace~54429c37-4045-4a7c-8a63-dc888dec1345/collection/26136776-740a4a1b-479f-4716-af2e-faba52e58f30?action=share&creator=26136776&source=collection_link"
"_collection_link": "https://warped-shadow-814178.postman.co/workspace/My-Workspace~54429c37-4045-4a7c-8a63-dc888dec1345/collection/26136776-740a4a1b-479f-4716-af2e-faba52e58f30?action=share&source=collection_link&creator=26136776"
},
"item": [
{
Expand All @@ -17,7 +17,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"creator\": \"Ofir\",\n \"creation_timestamp\": 45235235,\n \"notification\": {\n \"name\": \"Testing\",\n \"type\": \"Location\",\n \"location\": \"Home\"\n },\n \"users\": [\n \"Dekel\",\n \"Lin\"\n ]\n}",
"raw": "",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -49,7 +49,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"creator\": \"MaTaSaS\",\n \"description\": \"Perm Arrival destination\",\n \"notification\": {\n \"name\": \"Perm Location Arrival Notification\",\n \"type\": \"Location\",\n \"location\": \"Work\",\n \"activation\": \"Arrival\",\n \"permanent\": \"true\"\n },\n \"users\": [\n \"MaTaSaS\"\n ]\n}",
"raw": "{\n \"creator\": \"linkimos\",\n \"description\": \"location desc\",\n \"notification\": {\n \"name\": \"Testing location\",\n \"type\": \"Location\",\n \"location\": \"Home\",\n \"permanent\": \"true\",\n \"activation\": \"Arrival\"\n },\n \"shouldBeNotified\": \"linkimos\",\n \"users\": [\n \"MaTaSaS\"\n ]\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -105,7 +105,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"creator\": \"MaTaSaS\",\n \"description\": \"This is a time notification\",\n \"notification\": {\n \"name\": \"Timer Notification\",\n \"type\": \"Time\",\n \"timestamp\": 1683999900\n },\n \"users\": [\n \"MaTaSaS\"\n ]\n}",
"raw": "{\n \"creator\": \"MaTaSaS\",\n \"description\": \"This is a time notification\",\n \"notification\": {\n \"name\": \"Timer Notification\",\n \"type\": \"Time\",\n \"timestamp\": 1693936080\n },\n \"users\": [\n \"MaTaSaS\"\n ]\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -133,7 +133,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"notifications\": [\n \"64d52b18c77b86c624ff4e74\"\n ],\n \"status\": \"Active\"\n}",
"raw": "{\n \"notifications\": [\n \"64e62254cb3daa47b0232ff8\"\n ],\n \"status\": \"Arrived\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -295,7 +295,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"id\": \"64d52b18c77b86c624ff4e74\",\n \"name\": \"Timer Notification 1\",\n \"description\": \"This is a time notification\",\n \"type\": \"Time\",\n \"timestamp\": 37346306400\n}",
"raw": "{\n \"id\": \"64d52b18c77b86c624ff4e74\",\n \"name\": \"Timer Notification 1\",\n \"description\": \"This is a time notification\",\n \"type\": \"Time\",\n \"timestamp\": 10000000\n}",
"options": {
"raw": {
"language": "json"
Expand Down
4 changes: 2 additions & 2 deletions Notify/Notify/Notify.Android/Managers/AndroidWiFiManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private static void sendNotificationsForArrivalDestinations(List<Notification> n
if (notification.ShouldBeNotified.Equals(notification.Creator))
{
r_Logger.LogInformation($"Sending newsfeed to creator {notification.Creator} for arrival notification: {notification.Name}");
AzureHttpClient.Instance.SendNewsfeed(new Newsfeed(notification.Creator, $"{notification.Target} Arrived {notification.TypeInfo}", $"{notification.Target} has arrived to {notification.TypeInfo}"));
AzureHttpClient.Instance.SendNewsfeed(new Newsfeed(notification.Creator, $"{notification.Target} Arrived {notification.TypeInfo}", $"{notification.Target} has arrived to their {notification.TypeInfo} destination"));
}
else
{
Expand Down Expand Up @@ -202,7 +202,7 @@ private static void sendNotificationsForLeaveDestinations(List<Notification> not
if(notification.ShouldBeNotified.Equals(notification.Creator))
{
r_Logger.LogInformation($"Sending newsfeed to creator {notification.Creator} for leave notification: {notification.Name}");
AzureHttpClient.Instance.SendNewsfeed(new Newsfeed(notification.Creator, $"{notification.Target} Left {notification.TypeInfo}", $"{notification.Target} has left {notification.TypeInfo}"));
AzureHttpClient.Instance.SendNewsfeed(new Newsfeed(notification.Creator, $"{notification.Target} Left {notification.TypeInfo}", $"{notification.Target} has left their {notification.TypeInfo} destination"));
}
else
{
Expand Down
24 changes: 20 additions & 4 deletions Notify/Notify/Notify/AppShell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,16 @@ private void getAllNotificationsForArrivalDestinations(Location location, ref Li
{
if (isArrivalNotification)
{
r_Logger.LogInformation($"Sending notification for arrival notification: {notification.Name}");
DependencyService.Get<INotificationManager>().SendNotification(notification);
if (notification.ShouldBeNotified.Equals(notification.Creator))
{
r_Logger.LogInformation($"Sending newsfeed to creator {notification.Creator} for arrival notification: {notification.Name}");
AzureHttpClient.Instance.SendNewsfeed(new Newsfeed(notification.Creator, $"{notification.Target} Arrived {notification.TypeInfo}", $"{notification.Target} has arrived to their {notification.TypeInfo} destination"));
}
else
{
r_Logger.LogInformation($"Sending notification for arrival notification: {notification.Name}");
DependencyService.Get<INotificationManager>().SendNotification(notification);
}

if (notification.IsPermanent)
{
Expand Down Expand Up @@ -298,8 +306,16 @@ private void getAllNotificationsForLeaveDestinations(Location location, ref List
{
if (isLeaveNotification)
{
r_Logger.LogInformation($"Sending notification for leave notification: {notification.Name}");
DependencyService.Get<INotificationManager>().SendNotification(notification);
if (notification.ShouldBeNotified.Equals(notification.Creator))
{
r_Logger.LogInformation($"Sending newsfeed to creator {notification.Creator} for leave notification: {notification.Name}");
AzureHttpClient.Instance.SendNewsfeed(new Newsfeed(notification.Creator, $"{notification.Target} Left {notification.TypeInfo}", $"{notification.Target} has left their {notification.TypeInfo} destination"));
}
else
{
r_Logger.LogInformation($"Sending notification for leave notification: {notification.Name}");
DependencyService.Get<INotificationManager>().SendNotification(notification);
}

if(notification.IsPermanent)
{
Expand Down
28 changes: 20 additions & 8 deletions Notify/Notify/Notify/Bluetooth/BluetoothManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ private void onDeviceConnectionLost(object sender, EventArgs e)
{
BluetoothSelectionList.Remove(args.Device.Name);
}
else if (e is DeviceErrorEventArgs errorArgs)
{
BluetoothSelectionList.Remove(errorArgs.Device.Name);
}

notificationsJson = Preferences.Get(Constants.PREFERENCES_NOTIFICATIONS, string.Empty);
destinationsJson = Preferences.Get(Constants.PREFERENCES_DESTINATIONS, string.Empty);
Expand Down Expand Up @@ -220,8 +216,16 @@ private void sendNotificationsForArrivalDestinations(List<Notification> notifica
{
if (isArrivalNotification)
{
r_Logger.LogInformation($"Sending notification for arrival notification: {notification.Name}");
DependencyService.Get<INotificationManager>().SendNotification(notification);
if (notification.ShouldBeNotified.Equals(notification.Creator))
{
r_Logger.LogInformation($"Sending newsfeed to creator {notification.Creator} for arrival notification: {notification.Name}");
AzureHttpClient.Instance.SendNewsfeed(new Newsfeed(notification.Creator, $"{notification.Target} Arrived {notification.TypeInfo}", $"{notification.Target} has arrived to their {notification.TypeInfo} destination"));
}
else
{
r_Logger.LogInformation($"Sending notification for arrival notification: {notification.Name}");
DependencyService.Get<INotificationManager>().SendNotification(notification);
}

if (notification.IsPermanent)
{
Expand Down Expand Up @@ -263,8 +267,16 @@ private void sendNotificationsForLeaveDestinations(List<Notification> notificati
{
if (isLeaveNotification)
{
r_Logger.LogInformation($"Sending notification for leave notification: {notification.Name}");
DependencyService.Get<INotificationManager>().SendNotification(notification);
if (notification.ShouldBeNotified.Equals(notification.Creator))
{
r_Logger.LogInformation($"Sending newsfeed to creator {notification.Creator} for leave notification: {notification.Name}");
AzureHttpClient.Instance.SendNewsfeed(new Newsfeed(notification.Creator, $"{notification.Target} Left {notification.TypeInfo}", $"{notification.Target} has left their {notification.TypeInfo} destination"));
}
else
{
r_Logger.LogInformation($"Sending notification for leave notification: {notification.Name}");
DependencyService.Get<INotificationManager>().SendNotification(notification);
}

if(notification.IsPermanent)
{
Expand Down

0 comments on commit 4c511a6

Please sign in to comment.