feat(accounts): add consent settings and organization management

This commit is contained in:
TakuyaYagam1 committed 2026-10-07 13:00:39 +03:00
1 parent 24638d46d2
commit 391af7a1ef
83 files changed
+10198 -613

No files matched your search

@@ -0,0 +1,55 @@
package domain
import (
"fmt"
"time"
"github.com/google/uuid"
)
type AccountDeletionRequestStatus string
const (
AccountDeletionRequestStatusRequested AccountDeletionRequestStatus = "requested"
AccountDeletionRequestStatusProcessing AccountDeletionRequestStatus = "processing"
)
type AccountDeletionRequest struct {
id uuid.UUID
subjectID uuid.UUID
status AccountDeletionRequestStatus
requestedAt time.Time
}
func NewAccountDeletionRequest(subjectID uuid.UUID, requestedAt time.Time) (AccountDeletionRequest, error) {
if subjectID == uuid.Nil || requestedAt.IsZero() {
return AccountDeletionRequest{}, fmt.Errorf("domain.NewAccountDeletionRequest - subject and request time must be set: %w", ErrInvalidConsent)
}
id, err := uuid.NewV7()
if err != nil {
return AccountDeletionRequest{}, fmt.Errorf("domain.NewAccountDeletionRequest - generate ID: %w", err)
}
return AccountDeletionRequest{
id: id, subjectID: subjectID, status: AccountDeletionRequestStatusRequested, requestedAt: requestedAt,
}, nil
}
func RestoreAccountDeletionRequest(id, subjectID uuid.UUID, status string, requestedAt time.Time) (AccountDeletionRequest, error) {
if id == uuid.Nil || subjectID == uuid.Nil || requestedAt.IsZero() ||
(status != string(AccountDeletionRequestStatusRequested) && status != string(AccountDeletionRequestStatusProcessing)) {
return AccountDeletionRequest{}, fmt.Errorf("domain.RestoreAccountDeletionRequest - stored request is invalid: %w", ErrInvalidConsent)
}
return AccountDeletionRequest{
id: id, subjectID: subjectID, status: AccountDeletionRequestStatus(status), requestedAt: requestedAt,
}, nil
}
func (request AccountDeletionRequest) ID() uuid.UUID { return request.id }
func (request AccountDeletionRequest) SubjectID() uuid.UUID { return request.subjectID }
func (request AccountDeletionRequest) Status() AccountDeletionRequestStatus { return request.status }
func (request AccountDeletionRequest) RequestedAt() time.Time { return request.requestedAt }
func (request AccountDeletionRequest) IsZero() bool { return request.id == uuid.Nil }
+11
View File
@@ -692,6 +692,17 @@ func NewPublicationEvent(change PublicationChange, at time.Time) (PrivacyEvent,
return completeEvent(location, event)
}
// NewConsentRevokedPublicationEvent records the closure caused by revoking
// C2. The event deliberately carries neither published fields nor a consent
// identifier; the consent ledger and publication table remain the sources of
// the detailed history.
func NewConsentRevokedPublicationEvent(userID uuid.UUID, at time.Time) (PrivacyEvent, error) {
const location = "domain.NewConsentRevokedPublicationEvent"
return completeEvent(location, PrivacyEvent{
userID: userID, kind: PrivacyEventPublicationClosed, occurredAt: at,
})
}
// NewSearchStatusEvent records a change of the search status.
func NewSearchStatusEvent(change SearchStatusChange, at time.Time) (PrivacyEvent, error) {
const location = "domain.NewSearchStatusEvent"