MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / UpsertUser

Method UpsertUser

internal/users/memory.go:24–39  ·  view source on GitHub ↗

─── User CRUD ────────────────────────────────────────────────────────────────

(user User)

Source from the content-addressed store, hash-verified

22// ─── User CRUD ────────────────────────────────────────────────────────────────
23
24func (s *MemoryStore) UpsertUser(user User) (User, error) {
25 s.mu.Lock()
26 defer s.mu.Unlock()
27 if user.CreatedAt.IsZero() {
28 user.CreatedAt = time.Now().UTC()
29 }
30 if user.Status == "" {
31 user.Status = StatusActive
32 }
33 if user.DataLimitResetStrategy == "" {
34 user.DataLimitResetStrategy = ResetStrategyNoReset
35 }
36 user.UsedBytes = user.UploadBytes + user.DownloadBytes
37 s.users[user.ID] = user
38 return user, nil
39}
40
41func (s *MemoryStore) GetUser(id string) (User, error) {
42 s.mu.RLock()

Calls

no outgoing calls