Initial commit: Open sourcing all of the Maple Open Technologies code.

This commit is contained in:
Bartlomiej Mika 2025-12-02 14:33:08 -05:00
commit 755d54a99d
2010 changed files with 448675 additions and 0 deletions

View file

@ -0,0 +1,38 @@
// codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/internal/repo/user/anonymize_user_ips.go
package user
import (
"context"
"time"
"github.com/gocql/gocql"
"go.uber.org/zap"
)
// AnonymizeUserIPs immediately anonymizes all IP addresses for a specific user
// Used for GDPR right-to-be-forgotten implementation
func (impl *userStorerImpl) AnonymizeUserIPs(ctx context.Context, userID gocql.UUID) error {
impl.logger.Info("Anonymizing IPs for specific user (GDPR mode)",
zap.String("user_id", userID.String()))
// Update the user record to anonymize all IP addresses
query := `
UPDATE maplefile.users_by_id
SET created_from_ip_address = '0.0.0.0',
modified_from_ip_address = '0.0.0.0',
ip_anonymized_at = ?
WHERE id = ?
`
if err := impl.session.Query(query, time.Now(), userID).WithContext(ctx).Exec(); err != nil {
impl.logger.Error("Failed to anonymize user IPs",
zap.String("user_id", userID.String()),
zap.Error(err))
return err
}
impl.logger.Info("✅ Successfully anonymized user IPs",
zap.String("user_id", userID.String()))
return nil
}