part of group messages history

This commit is contained in:
2026-04-12 14:39:24 +02:00
parent 3be9619cca
commit 09a6255213
4 changed files with 53 additions and 13 deletions
+43
View File
@@ -0,0 +1,43 @@
package main
import (
"context"
"github.com/google/uuid"
)
func GetUserById(ctx context.Context, userId uuid.UUID) (*User, error) {
user, err := CacheGetUserById(userId)
if err != nil {
user = &User{Id: userId}
err = DbGetWholeUser(ctx, user)
if err != nil {
return nil, err
}
}
return user, nil
}
func GetUserByToken(ctx context.Context, token string) (*User, error) {
userId, err := TokenValidateGetId(token)
if err != nil {
return nil, err
}
return GetUserById(ctx, userId)
}
func GetGroup(ctx context.Context, groupId uuid.UUID) (*Group, error) {
group, err := CacheGetGroup(groupId)
if err != nil {
group = &Group{Id: groupId}
if err = DbGroupGetById(ctx, group); err != nil {
return nil, err
}
if err = DbGroupGetMembers(ctx, group); err != nil {
return nil, err
}
CacheSaveGroup(group)
}
return group, nil
}