fix: make ai task events realtime only
This commit is contained in:
@@ -67,13 +67,14 @@ func executeKafkaWorkbenchEvent(event kafkaWorkbenchEvent) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
notificationEnabled := event.shouldCreateNotification()
|
||||
pushTargets := make(map[types.Uid]push.Recipient)
|
||||
for _, targetID := range event.TargetUserIDs {
|
||||
target := store.EncodeUid(targetID)
|
||||
if target.IsZero() {
|
||||
continue
|
||||
}
|
||||
if target != actor && event.Title != "" {
|
||||
if notificationEnabled && target != actor && event.Title != "" {
|
||||
action := event.notificationAction()
|
||||
if err = createIMSystemNotification(event.TenantID, target, stableIMEventID(event.EventID, "notification", target.UserId()),
|
||||
event.Action, event.Title, event.Summary, action); err != nil && err != types.ErrDuplicate {
|
||||
@@ -133,6 +134,15 @@ func (e kafkaWorkbenchEvent) realtimePayload() (map[string]any, error) {
|
||||
return payload, nil
|
||||
}
|
||||
|
||||
func (e kafkaWorkbenchEvent) shouldCreateNotification() bool {
|
||||
switch e.Action {
|
||||
case "workbench.ai.task.updated":
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func (e kafkaWorkbenchEvent) notificationAction() types.KVMap {
|
||||
action := types.KVMap{
|
||||
"module": e.Module,
|
||||
|
||||
Reference in New Issue
Block a user