mirror of
https://github.com/aykhans/slash-e.git
synced 2025-09-05 16:54:18 +00:00
chore: move api to route package
This commit is contained in:
33
server/route/api/v1/common.go
Normal file
33
server/route/api/v1/common.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
apiv1pb "github.com/yourselfhosted/slash/proto/gen/api/v1"
|
||||
"github.com/yourselfhosted/slash/store"
|
||||
)
|
||||
|
||||
func convertRowStatusFromStore(rowStatus store.RowStatus) apiv1pb.RowStatus {
|
||||
switch rowStatus {
|
||||
case store.Normal:
|
||||
return apiv1pb.RowStatus_NORMAL
|
||||
case store.Archived:
|
||||
return apiv1pb.RowStatus_ARCHIVED
|
||||
default:
|
||||
return apiv1pb.RowStatus_ROW_STATUS_UNSPECIFIED
|
||||
}
|
||||
}
|
||||
|
||||
func getCurrentUser(ctx context.Context, s *store.Store) (*store.User, error) {
|
||||
userID, ok := ctx.Value(userIDContextKey).(int32)
|
||||
if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
user, err := s.GetUser(ctx, &store.FindUser{
|
||||
ID: &userID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return user, nil
|
||||
}
|
Reference in New Issue
Block a user