Skip to content

Commit

Permalink
Update and modernize code, update dependencies (part 2)
Browse files Browse the repository at this point in the history
  • Loading branch information
krusche committed Oct 5, 2024
1 parent 1005f93 commit 3b3a6d0
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 58 deletions.
2 changes: 1 addition & 1 deletion apns/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
id 'io.spring.dependency-management'
}

group = 'de.tum.cit.aet.artemis.push.artemispushnotificationrelay'
group = 'de.tum.cit.aet.artemis.push'
version = '1.0.0'

java {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package de.tum.cit.artemis.push.artemispushnotificationrelay.apns;
package de.tum.cit.artemis.push.apns;

import com.eatthepath.pushy.apns.*;
import com.eatthepath.pushy.apns.util.SimpleApnsPayloadBuilder;
import com.eatthepath.pushy.apns.util.SimpleApnsPushNotification;
import com.eatthepath.pushy.apns.util.concurrent.PushNotificationFuture;
import de.tum.cit.artemis.push.artemispushnotificationrelay.common.NotificationRequest;
import de.tum.cit.artemis.push.artemispushnotificationrelay.common.SendService;
import de.tum.cit.artemis.push.common.NotificationRequest;
import de.tum.cit.artemis.push.common.SendService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -86,9 +86,7 @@ private ResponseEntity<Void> sendApnsRequest(NotificationRequest request) {
} else {
log.error("Notification rejected by the APNs gateway: {}", pushNotificationResponse.getRejectionReason());

pushNotificationResponse.getTokenInvalidationTimestamp().ifPresent(timestamp -> {
log.error("\t…and the token is invalid as of {}", timestamp);
});
pushNotificationResponse.getTokenInvalidationTimestamp().ifPresent(timestamp -> log.error("\t... and the token is invalid as of {}", timestamp));
return ResponseEntity.status(HttpStatus.EXPECTATION_FAILED).build();
}
} catch (ExecutionException | InterruptedException e) {
Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
id 'io.spring.dependency-management'
}

group = 'de.tum.cit.aet.artemis.push.artemispushnotificationrelay'
group = 'de.tum.cit.aet.artemis.push'
version = '1.0.0'

java {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.tum.cit.artemis.push.artemispushnotificationrelay.common;
package de.tum.cit.artemis.push.common;

public record NotificationRequest(String initializationVector, String payloadCipherText, String token) {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.tum.cit.artemis.push.artemispushnotificationrelay.common;
package de.tum.cit.artemis.push.common;

import org.springframework.http.ResponseEntity;

Expand Down
4 changes: 2 additions & 2 deletions firebase/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
id 'io.spring.dependency-management'
}

group = 'de.tum.cit.aet.artemis.push.artemispushnotificationrelay'
group = 'de.tum.cit.aet.artemis.push'
version = '1.0.0'

java {
Expand All @@ -20,7 +20,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-web'

implementation "com.google.firebase:firebase-admin:9.1.1"
implementation "com.google.firebase:firebase-admin:9.3.0"
implementation(project(":common"))
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package de.tum.cit.artemis.push.firebase;

import de.tum.cit.artemis.push.common.NotificationRequest;

import java.util.List;

public record FirebaseSendPushNotificationsRequest(List<NotificationRequest> notificationRequest) {
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package de.tum.cit.artemis.push.artemispushnotificationrelay.firebase;
package de.tum.cit.artemis.push.firebase;

import com.google.auth.oauth2.GoogleCredentials;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import com.google.firebase.messaging.FirebaseMessaging;
import com.google.firebase.messaging.FirebaseMessagingException;
import com.google.firebase.messaging.Message;
import de.tum.cit.artemis.push.artemispushnotificationrelay.common.NotificationRequest;
import de.tum.cit.artemis.push.artemispushnotificationrelay.common.SendService;
import de.tum.cit.artemis.push.common.NotificationRequest;
import de.tum.cit.artemis.push.common.SendService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.tum.cit.artemis.push.artemispushnotificationrelay;
package de.tum.cit.artemis.push;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package de.tum.cit.artemis.push;

import de.tum.cit.artemis.push.apns.ApnsSendService;
import de.tum.cit.artemis.push.common.NotificationRequest;
import de.tum.cit.artemis.push.firebase.FirebaseSendPushNotificationsRequest;
import de.tum.cit.artemis.push.firebase.FirebaseSendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/push_notification")
public class RelayRestController {

private final FirebaseSendService firebaseSendService;

private final ApnsSendService apnsSendService;

public RelayRestController(FirebaseSendService firebaseSendService, ApnsSendService apnsSendService) {
this.firebaseSendService = firebaseSendService;
this.apnsSendService = apnsSendService;
}

@PostMapping("send_firebase")
public ResponseEntity<Void> send(@RequestBody FirebaseSendPushNotificationsRequest notificationRequests) {
return firebaseSendService.send(notificationRequests.notificationRequest());
}

@PostMapping("send_apns")
public ResponseEntity<Void> send(@RequestBody NotificationRequest notificationRequest) {
return apnsSendService.send(notificationRequest);
}

@GetMapping("alive")
public ResponseEntity<Void> alive() {
return ResponseEntity.ok().build();
}
}

This file was deleted.

0 comments on commit 3b3a6d0

Please sign in to comment.