Changeset 0.28.2 (#183)
This commit is contained in:
@@ -144,3 +144,68 @@ func NotifyGroupMemberRemoved(svc *Service, userID, groupID, groupName string) {
|
||||
log.Printf("[notifications] grant.changed (remove) failed for user %s: %v", userID, err)
|
||||
}
|
||||
}
|
||||
|
||||
// ── Memory Extraction ──────────────────────
|
||||
// Called from memory/extractor.go after successful extraction.
|
||||
|
||||
// NotifyMemoryExtracted creates a notification when new memories are extracted.
|
||||
func NotifyMemoryExtracted(svc *Service, userID, channelID string, count int) {
|
||||
if svc == nil {
|
||||
return
|
||||
}
|
||||
title := fmt.Sprintf("%d new memories extracted", count)
|
||||
if count == 1 {
|
||||
title = "1 new memory extracted"
|
||||
}
|
||||
n := models.Notification{
|
||||
UserID: userID,
|
||||
Type: models.NotifTypeMemoryExtracted,
|
||||
Title: title,
|
||||
ResourceType: models.ResourceTypeChannel,
|
||||
ResourceID: channelID,
|
||||
}
|
||||
if err := svc.Notify(context.Background(), &n); err != nil {
|
||||
log.Printf("[notifications] memory.extracted failed for user %s: %v", userID, err)
|
||||
}
|
||||
}
|
||||
|
||||
// ── User Mention ───────────────────────────
|
||||
// Called from handlers/completion.go when an @mention targets a human user.
|
||||
|
||||
// NotifyUserMentioned creates a persisted notification for an @mention.
|
||||
func NotifyUserMentioned(svc *Service, mentionedUserID, channelID, fromUserID, preview string) {
|
||||
if svc == nil {
|
||||
return
|
||||
}
|
||||
n := models.Notification{
|
||||
UserID: mentionedUserID,
|
||||
Type: models.NotifTypeUserMentioned,
|
||||
Title: "You were mentioned in a conversation",
|
||||
Body: preview,
|
||||
ResourceType: models.ResourceTypeChannel,
|
||||
ResourceID: channelID,
|
||||
}
|
||||
if err := svc.Notify(context.Background(), &n); err != nil {
|
||||
log.Printf("[notifications] user.mentioned failed for user %s: %v", mentionedUserID, err)
|
||||
}
|
||||
}
|
||||
|
||||
// ── Workflow Claimed ───────────────────────
|
||||
// Called from handlers/workflow_assignments.go when a user claims an assignment.
|
||||
|
||||
// NotifyWorkflowClaimed creates a persisted notification when an assignment is claimed.
|
||||
func NotifyWorkflowClaimed(svc *Service, claimerID, assignmentID, channelID string) {
|
||||
if svc == nil {
|
||||
return
|
||||
}
|
||||
n := models.Notification{
|
||||
UserID: claimerID,
|
||||
Type: models.NotifTypeWorkflowClaimed,
|
||||
Title: "You claimed a workflow assignment",
|
||||
ResourceType: models.ResourceTypeChannel,
|
||||
ResourceID: channelID,
|
||||
}
|
||||
if err := svc.Notify(context.Background(), &n); err != nil {
|
||||
log.Printf("[notifications] workflow.claimed failed for user %s: %v", claimerID, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user