This commit is contained in:
@@ -28,6 +28,8 @@ var (
|
||||
ErrDeviceClaimInvalid = errors.New("device claim is invalid")
|
||||
ErrDeviceClaimUsed = errors.New("device claim was used for another binding")
|
||||
ErrDeviceAlreadyBound = errors.New("device already has an active binding")
|
||||
ErrDeviceBindingBlocked = errors.New("device binding change has active blockers")
|
||||
ErrDeviceBindingStale = errors.New("device binding changed since impact review")
|
||||
ErrSubjectDeleteConflict = errors.New("subject cannot be deleted while a conversation is active")
|
||||
ErrDeleteConfirmation = errors.New("subject deletion confirmation does not match")
|
||||
)
|
||||
@@ -126,6 +128,11 @@ type Service struct {
|
||||
exportDownloadTTL time.Duration
|
||||
firmwareStore firmwareObjectStore
|
||||
firmwareURLTTL time.Duration
|
||||
providerMemory bool
|
||||
}
|
||||
|
||||
func (s *Service) ConfigureProviderMemory(enabled bool) {
|
||||
s.providerMemory = enabled
|
||||
}
|
||||
|
||||
func NewService(pool *pgxpool.Pool, auditRepository *audit.Repository, redisClient *redis.Client, cursorCodec *pagination.Codec) *Service {
|
||||
@@ -506,6 +513,32 @@ func (s *Service) WithdrawConsent(ctx context.Context, principal identity.Princi
|
||||
WHERE tenant_id=$1::uuid AND subject_id=$2::uuid AND status IN ('PENDING','ACTIVE')`, access.tenantID, access.subjectID); err != nil {
|
||||
return fmt.Errorf("invalidate memory index after consent withdrawal: %w", err)
|
||||
}
|
||||
if s.providerMemory {
|
||||
rows, err := tx.Query(ctx, `SELECT id::text FROM curated_memory WHERE tenant_id=$1::uuid AND subject_id=$2::uuid AND status<>'DELETED' ORDER BY id`, access.tenantID, access.subjectID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("list provider memories after consent withdrawal: %w", err)
|
||||
}
|
||||
memoryIDs := make([]string, 0)
|
||||
for rows.Next() {
|
||||
var memoryID string
|
||||
if err := rows.Scan(&memoryID); err != nil {
|
||||
rows.Close()
|
||||
return err
|
||||
}
|
||||
memoryIDs = append(memoryIDs, memoryID)
|
||||
}
|
||||
rows.Close()
|
||||
if err := rows.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, memoryID := range memoryIDs {
|
||||
dedupe := "memory-provider-delete-consent:" + memoryID + ":" + result.ID
|
||||
payload, _ := json.Marshal(map[string]string{"reason": "personalized memory consent withdrawn", "consent_id": result.ID})
|
||||
if _, err := outbox.NewStore(s.pool).Enqueue(ctx, tx, outbox.NewEvent{TenantID: &access.tenantID, AggregateType: "curated_memory", AggregateID: memoryID, EventType: "memory.provider_delete_requested", DeduplicationKey: &dedupe, Payload: payload}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
affectedConversations, err := s.stopConversationsAfterConsentWithdrawal(ctx, tx, access.tenantID, access.subjectID, result.Type)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user