- Implemented notification event publishing with a new NotificationEventPublisher interface. - Created a noopNotificationEventPublisher for testing purposes. - Added functionality to publish notification created events via MQTT. - Introduced a new stream event publisher for handling job logs and updates. - Added database migration for popup_ads table. - Created tests for notification events and popup ads functionality. - Established MQTT connection and publishing helpers for event messages.
92 lines
1.5 KiB
Go
92 lines
1.5 KiB
Go
package service
|
|
|
|
import (
|
|
"strings"
|
|
"time"
|
|
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
|
)
|
|
|
|
func stringPointerOrNil(value string) *string {
|
|
trimmed := strings.TrimSpace(value)
|
|
if trimmed == "" {
|
|
return nil
|
|
}
|
|
return &trimmed
|
|
}
|
|
|
|
func timeToProto(value *time.Time) *timestamppb.Timestamp {
|
|
if value == nil {
|
|
return nil
|
|
}
|
|
return timestamppb.New(value.UTC())
|
|
}
|
|
|
|
func boolValue(value *bool) bool {
|
|
return value != nil && *value
|
|
}
|
|
|
|
func stringValue(value *string) string {
|
|
if value == nil {
|
|
return ""
|
|
}
|
|
return *value
|
|
}
|
|
|
|
func int32PtrToInt64Ptr(value *int32) *int64 {
|
|
if value == nil {
|
|
return nil
|
|
}
|
|
converted := int64(*value)
|
|
return &converted
|
|
}
|
|
|
|
func int64PtrToInt32Ptr(value *int64) *int32 {
|
|
if value == nil {
|
|
return nil
|
|
}
|
|
converted := int32(*value)
|
|
return &converted
|
|
}
|
|
|
|
func int32Ptr(value int32) *int32 {
|
|
return &value
|
|
}
|
|
|
|
func protoTimestampToTime(value *timestamppb.Timestamp) *time.Time {
|
|
if value == nil {
|
|
return nil
|
|
}
|
|
timeValue := value.AsTime().UTC()
|
|
return &timeValue
|
|
}
|
|
|
|
func protoStringValue(value *string) string {
|
|
if value == nil {
|
|
return ""
|
|
}
|
|
return strings.TrimSpace(*value)
|
|
}
|
|
|
|
func nullableTrimmedStringPtr(value *string) *string {
|
|
if value == nil {
|
|
return nil
|
|
}
|
|
trimmed := strings.TrimSpace(*value)
|
|
if trimmed == "" {
|
|
return nil
|
|
}
|
|
return &trimmed
|
|
}
|
|
|
|
func nullableTrimmedString(value *string) *string {
|
|
if value == nil {
|
|
return nil
|
|
}
|
|
trimmed := strings.TrimSpace(*value)
|
|
if trimmed == "" {
|
|
return nil
|
|
}
|
|
return &trimmed
|
|
}
|