A community based topic aggregation platform built on atproto
1package users
2
3import "context"
4
5// UserRepository defines the interface for user data persistence
6type UserRepository interface {
7 Create(ctx context.Context, user *User) (*User, error)
8 GetByDID(ctx context.Context, did string) (*User, error)
9 GetByHandle(ctx context.Context, handle string) (*User, error)
10 UpdateHandle(ctx context.Context, did, newHandle string) (*User, error)
11
12 // GetByDIDs retrieves multiple users by their DIDs in a single batch query.
13 // Returns a map of DID → User for efficient lookups.
14 // Missing users are not included in the result map (no error for missing users).
15 // Returns error only on database failures or validation errors (invalid DIDs, batch too large).
16 //
17 // Parameters:
18 // - ctx: Context for cancellation and timeout
19 // - dids: Array of DIDs to retrieve (must start with "did:", max 1000 items)
20 //
21 // Returns:
22 // - map[string]*User: Map of DID → User for found users
23 // - error: Validation or database errors (not errors for missing users)
24 //
25 // Example:
26 // userMap, err := repo.GetByDIDs(ctx, []string{"did:plc:abc", "did:plc:xyz"})
27 // if err != nil { return err }
28 // if user, found := userMap["did:plc:abc"]; found {
29 // // Use user
30 // }
31 GetByDIDs(ctx context.Context, dids []string) (map[string]*User, error)
32}
33
34// UserService defines the interface for user business logic
35type UserService interface {
36 CreateUser(ctx context.Context, req CreateUserRequest) (*User, error)
37 GetUserByDID(ctx context.Context, did string) (*User, error)
38 GetUserByHandle(ctx context.Context, handle string) (*User, error)
39 UpdateHandle(ctx context.Context, did, newHandle string) (*User, error)
40 ResolveHandleToDID(ctx context.Context, handle string) (string, error)
41 RegisterAccount(ctx context.Context, req RegisterAccountRequest) (*RegisterAccountResponse, error)
42}