Skip to content

Commit

Permalink
Add missing class NotificationLoggingManager
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesChenX committed Jun 12, 2024
1 parent 3f6a7e3 commit 0dde207
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import im.turms.gateway.domain.session.manager.UserSessionsManager;
import im.turms.gateway.domain.session.service.SessionService;
import im.turms.gateway.infra.logging.ApiLoggingContext;
import im.turms.gateway.infra.logging.NotificationLogging;
import im.turms.gateway.infra.logging.NotificationLoggingManager;
import im.turms.gateway.infra.plugin.extension.NotificationHandler;
import im.turms.gateway.infra.proto.SimpleTurmsNotification;
import im.turms.gateway.infra.proto.TurmsNotificationParser;
Expand Down Expand Up @@ -64,6 +64,7 @@ public class NotificationService implements RpcNotificationService {

private final ApiLoggingContext apiLoggingContext;
private final SessionService sessionService;
private final NotificationLoggingManager notificationLoggingManager;
private final PluginManager pluginManager;

private final boolean isNotificationLoggingEnabled;
Expand All @@ -80,10 +81,12 @@ public class NotificationService implements RpcNotificationService {
public NotificationService(
ApiLoggingContext apiLoggingContext,
SessionService sessionService,
NotificationLoggingManager notificationLoggingManager,
PluginManager pluginManager,
TurmsPropertiesManager propertiesManager) {
this.apiLoggingContext = apiLoggingContext;
this.sessionService = sessionService;
this.notificationLoggingManager = notificationLoggingManager;
this.pluginManager = pluginManager;
isNotificationLoggingEnabled = propertiesManager.getLocalProperties()
.getGateway()
Expand Down Expand Up @@ -182,7 +185,7 @@ public Mono<Set<Long>> sendNotificationToLocalClients(
int notificationBytes = notificationData.readableBytes();
try (TracingCloseableContext ignored =
TracingContext.getCloseableContext(context)) {
NotificationLogging.log(notification,
notificationLoggingManager.log(notification,
notificationBytes,
recipientCount,
recipientCount - offlineRecipientCount);
Expand Down Expand Up @@ -230,4 +233,4 @@ private void invokeExtensionPointHandlers(
.subscribe(null, LOGGER::error);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
package im.turms.gateway.infra.logging;

import io.netty.buffer.ByteBuf;
import org.springframework.stereotype.Component;

import im.turms.gateway.infra.proto.SimpleTurmsNotification;
import im.turms.server.common.infra.lang.NumberFormatter;
import im.turms.server.common.infra.logging.BaseNotificationLoggingManager;
import im.turms.server.common.infra.netty.ByteBufUtil;

import static im.turms.server.common.infra.logging.CommonLogger.LOG_FIELD_DELIMITER;
Expand All @@ -29,12 +31,10 @@
/**
* @author James Chen
*/
public final class NotificationLogging {
@Component
public class NotificationLoggingManager extends BaseNotificationLoggingManager {

private NotificationLogging() {
}

public static void log(
public void log(
SimpleTurmsNotification notification,
int notificationBytes,
int recipientCount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import im.turms.gateway.domain.session.manager.UserSessionsManager;
import im.turms.gateway.domain.session.service.SessionService;
import im.turms.gateway.infra.logging.ApiLoggingContext;
import im.turms.gateway.infra.logging.NotificationLoggingManager;
import im.turms.gateway.infra.plugin.extension.NotificationHandler;
import im.turms.server.common.access.client.dto.constant.DeviceType;
import im.turms.server.common.access.client.dto.request.TurmsRequestTypePool;
Expand All @@ -60,7 +61,7 @@ void constructor_shouldReturnInstance() {
when(propertiesManager.getLocalProperties()).thenReturn(new TurmsProperties());

NotificationService notificationService =
new NotificationService(null, null, null, propertiesManager);
new NotificationService(null, null, null, null, propertiesManager);
assertThat(notificationService).isNotNull();
}

Expand Down Expand Up @@ -132,6 +133,8 @@ private NotificationService newOutboundMessageService(UserSessionsManager userSe
ApiLoggingContext apiLoggingContext = mock(ApiLoggingContext.class);
when(apiLoggingContext.shouldLogNotification(any())).thenReturn(true);

NotificationLoggingManager notificationLoggingManager =
mock(NotificationLoggingManager.class);
PluginManager pluginManager = mock(PluginManager.class);

TurmsPropertiesManager propertiesManager = mock(TurmsPropertiesManager.class);
Expand All @@ -142,6 +145,7 @@ private NotificationService newOutboundMessageService(UserSessionsManager userSe
return new NotificationService(
apiLoggingContext,
sessionService,
notificationLoggingManager,
pluginManager,
propertiesManager);
}
Expand Down

0 comments on commit 0dde207

Please sign in to comment.