update naming of functions, add option to get count of unread messages of user
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package convertions
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -40,10 +41,30 @@ func Uint32ToRgba(v uint32) *types.Rgba {
|
||||
return &types.Rgba{uint8(v >> 24), uint8(v >> 16), uint8(v >> 8), uint8(v)}
|
||||
}
|
||||
|
||||
func ConvertStringUuid(str string) (uuid.UUID, error) {
|
||||
func StringToUuid(str string) (uuid.UUID, error) {
|
||||
return uuid.Parse(str)
|
||||
}
|
||||
|
||||
func ConvertStringTimestamp(str string) (time.Time, error) {
|
||||
func StringToUuidSlice(uuidStr string) (*[]uuid.UUID, error) {
|
||||
if uuidStr == "" {
|
||||
return nil, errors.New("empty string")
|
||||
}
|
||||
|
||||
parts := strings.Split(uuidStr, ",")
|
||||
|
||||
slice := make([]uuid.UUID, len(parts))
|
||||
|
||||
for _, part := range parts {
|
||||
id, err := StringToUuid(part)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
slice = append(slice, id)
|
||||
}
|
||||
return &slice, nil
|
||||
}
|
||||
|
||||
func StringToTimestamp(str string) (time.Time, error) {
|
||||
return time.Parse(time.RFC3339, str)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user