Фикс LazyInitializationException
All checks were successful
Build rosetta-wss / build (push) Successful in 1m45s
All checks were successful
Build rosetta-wss / build (push) Successful in 1m45s
This commit is contained in:
@@ -29,24 +29,38 @@ public class PushNotifyDispatcher {
|
||||
return this.pushers.get(tokenType);
|
||||
}
|
||||
|
||||
private List<PushToken> findPushTokens(String publicKey) {
|
||||
private List<RuntimeToken> findPushTokens(String publicKey) {
|
||||
List<Device> devices = this.deviceService.getDevicesByPK(publicKey);
|
||||
List<PushToken> pushTokens = new java.util.ArrayList<>();
|
||||
List<RuntimeToken> rtTokens = new java.util.ArrayList<>();
|
||||
for(Device device : devices){
|
||||
pushTokens.addAll(device.getTokens());
|
||||
for(PushToken pushToken : device.getTokens()){
|
||||
rtTokens.add(new RuntimeToken(pushToken.getType(), pushToken.getToken()));
|
||||
}
|
||||
}
|
||||
return pushTokens;
|
||||
return rtTokens;
|
||||
}
|
||||
|
||||
private List<RuntimeToken> findPushTokens(List<String> publicKeys) {
|
||||
List<RuntimeToken> rtTokens = new java.util.ArrayList<>();
|
||||
for(String publicKey : publicKeys){
|
||||
List<Device> devices = this.deviceService.getDevicesByPK(publicKey);
|
||||
for(Device device : devices){
|
||||
for(PushToken pushToken : device.getTokens()){
|
||||
rtTokens.add(new RuntimeToken(pushToken.getType(), pushToken.getToken()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return rtTokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Отправить уведомление пользователю с publicKey, используя все его токены для отправки уведомления, если таковые имеются
|
||||
* @param publicKey публичный ключ пользователя, которому нужно отправить уведомление
|
||||
* @param data данные уведомления
|
||||
*/
|
||||
public void sendPush(String publicKey, HashMap<String, String> data) {
|
||||
List<RuntimeToken> pushTokens = this.findPushTokens(publicKey);
|
||||
executor.execute(() -> {
|
||||
List<PushToken> pushTokens = this.findPushTokens(publicKey);
|
||||
for(PushToken pushToken : pushTokens){
|
||||
for(RuntimeToken pushToken : pushTokens){
|
||||
Pusher pusher = this.findPusher(pushToken.getType());
|
||||
if(pusher != null){
|
||||
pusher.sendPush(pushToken.getToken(), data);
|
||||
@@ -61,17 +75,16 @@ public class PushNotifyDispatcher {
|
||||
* @param data данные уведомления
|
||||
*/
|
||||
public void sendPush(List<String> publicKeys, HashMap<String, String> data) {
|
||||
List<RuntimeToken> pushTokens = this.findPushTokens(publicKeys);
|
||||
executor.execute(() -> {
|
||||
for(String publicKey : publicKeys){
|
||||
List<PushToken> pushTokens = this.findPushTokens(publicKey);
|
||||
for(PushToken pushToken : pushTokens){
|
||||
Pusher pusher = this.findPusher(pushToken.getType());
|
||||
for(RuntimeToken pushToken : pushTokens){
|
||||
Pusher pusher = this.findPusher(pushToken.getType());
|
||||
if(pusher != null){
|
||||
pusher.sendPush(pushToken.getToken(), data);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package im.rosetta.service.dispatch.push;
|
||||
|
||||
import im.rosetta.packet.runtime.TokenType;
|
||||
|
||||
public class RuntimeToken {
|
||||
|
||||
private TokenType type;
|
||||
private String token;
|
||||
|
||||
public RuntimeToken(TokenType type, String token) {
|
||||
this.type = type;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public TokenType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user