feat: add bell notification system for task assignment
This commit is contained in:
36
internal/utils/cursor.go
Normal file
36
internal/utils/cursor.go
Normal file
@ -0,0 +1,36 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func DecodeCursor(encodedCursor string) (res time.Time, id uuid.UUID, err error) {
|
||||
byt, err := base64.StdEncoding.DecodeString(encodedCursor)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
arrStr := strings.Split(string(byt), ",")
|
||||
if len(arrStr) != 2 {
|
||||
err = errors.New("cursor is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
res, err = time.Parse(time.RFC3339Nano, arrStr[0])
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
id = uuid.MustParse(arrStr[1])
|
||||
return
|
||||
}
|
||||
|
||||
func EncodeCursor(t time.Time, id uuid.UUID) string {
|
||||
key := fmt.Sprintf("%s,%s", t.Format(time.RFC3339Nano), id.String())
|
||||
return base64.StdEncoding.EncodeToString([]byte(key))
|
||||
}
|
Reference in New Issue
Block a user