Commit 4cef8eec authored by Denis Arh's avatar Denis Arh
Browse files

Tidy up id.Next() and time.Now() use

parent 3a7cc105
......@@ -6,7 +6,6 @@ import (
"github.com/cortezaproject/corteza-server/compose/types"
"github.com/cortezaproject/corteza-server/pkg/actionlog"
"github.com/cortezaproject/corteza-server/pkg/auth"
"github.com/cortezaproject/corteza-server/pkg/id"
"github.com/cortezaproject/corteza-server/pkg/objstore"
"github.com/cortezaproject/corteza-server/store"
"github.com/disintegration/imaging"
......@@ -155,7 +154,7 @@ func (svc attachment) DeleteByID(namespaceID, attachmentID uint64) (err error) {
aProps.setAttachment(att)
att.DeletedAt = nowPtr()
att.DeletedAt = now()
return store.UpdateComposeAttachment(ctx, s, att)
})
......@@ -348,7 +347,7 @@ func (svc attachment) create(name string, size int64, fh io.ReadSeeker, att *typ
)
// preset attachment ID because we need ref for storage
att.ID = id.Next()
att.ID = nextID()
if att.OwnerID == 0 {
att.OwnerID = auth.GetIdentityFromContext(svc.ctx).Identity()
......
......@@ -6,7 +6,6 @@ import (
"github.com/cortezaproject/corteza-server/compose/types"
"github.com/cortezaproject/corteza-server/pkg/actionlog"
"github.com/cortezaproject/corteza-server/pkg/handle"
"github.com/cortezaproject/corteza-server/pkg/id"
"github.com/cortezaproject/corteza-server/store"
)
......@@ -132,8 +131,8 @@ func (svc chart) Create(new *types.Chart) (*types.Chart, error) {
return ChartErrNotAllowedToCreate()
}
new.ID = id.Next()
new.CreatedAt = *nowPtr()
new.ID = nextID()
new.CreatedAt = *now()
new.UpdatedAt = nil
new.DeletedAt = nil
......@@ -249,7 +248,7 @@ func (svc chart) handleUpdate(upd *types.Chart) chartUpdateHandler {
c.Name = upd.Name
c.Handle = upd.Handle
c.Config = upd.Config
c.UpdatedAt = nowPtr()
c.UpdatedAt = now()
return true, nil
}
}
......@@ -264,7 +263,7 @@ func (svc chart) handleDelete(ctx context.Context, ns *types.Namespace, c *types
return false, nil
}
c.DeletedAt = nowPtr()
c.DeletedAt = now()
return true, nil
}
......
......@@ -4,7 +4,6 @@ import (
"context"
"errors"
"github.com/cortezaproject/corteza-server/compose/types"
"github.com/cortezaproject/corteza-server/pkg/id"
"github.com/cortezaproject/corteza-server/pkg/permissions"
"github.com/cortezaproject/corteza-server/store"
"github.com/cortezaproject/corteza-server/store/sqlite3"
......@@ -18,7 +17,7 @@ func TestCharts(t *testing.T) {
ctx = context.Background()
s, err = sqlite3.ConnectInMemory(ctx)
namespaceID = id.Next()
namespaceID = nextID()
ns *types.Namespace
)
......@@ -43,7 +42,7 @@ func TestCharts(t *testing.T) {
t.Fatalf("failed to truncate compose charts: %v", err)
}
ns = &types.Namespace{Name: "testing", ID: namespaceID, CreatedAt: *nowPtr()}
ns = &types.Namespace{Name: "testing", ID: namespaceID, CreatedAt: *now()}
if err = store.CreateComposeNamespace(ctx, s, ns); err != nil {
t.Fatalf("failed to seed namespaces: %v", err)
}
......
......@@ -4,7 +4,6 @@ import (
"context"
"fmt"
"github.com/cortezaproject/corteza-server/pkg/auth"
"github.com/cortezaproject/corteza-server/pkg/id"
"sync"
"time"
)
......@@ -64,7 +63,7 @@ func (svc *importSession) SetByID(ctx context.Context, sessionID, namespaceID, m
ris = svc.records[i]
} else {
ris = &RecordImportSession{
SessionID: id.Next(),
SessionID: nextID(),
CreatedAt: time.Now(),
}
svc.records = append(svc.records, ris)
......
......@@ -10,7 +10,6 @@ import (
"github.com/cortezaproject/corteza-server/pkg/eventbus"
"github.com/cortezaproject/corteza-server/pkg/filter"
"github.com/cortezaproject/corteza-server/pkg/handle"
"github.com/cortezaproject/corteza-server/pkg/id"
"github.com/cortezaproject/corteza-server/store"
"sort"
"strconv"
......@@ -187,15 +186,15 @@ func (svc module) Create(new *types.Module) (*types.Module, error) {
return err
}
new.ID = id.Next()
new.CreatedAt = *nowPtr()
new.ID = nextID()
new.CreatedAt = *now()
new.UpdatedAt = nil
new.DeletedAt = nil
if new.Fields != nil {
_ = new.Fields.Walk(func(f *types.ModuleField) error {
f.ModuleID = new.ID
f.CreatedAt = *nowPtr()
f.CreatedAt = *now()
f.UpdatedAt = nil
f.DeletedAt = nil
return nil
......@@ -387,7 +386,7 @@ func (svc module) handleUpdate(upd *types.Module) moduleUpdateHandler {
}
if mch {
m.UpdatedAt = nowPtr()
m.UpdatedAt = now()
}
// for now, we assume that
......@@ -405,7 +404,7 @@ func (svc module) handleDelete(ctx context.Context, ns *types.Namespace, m *type
return false, false, nil
}
m.DeletedAt = nowPtr()
m.DeletedAt = now()
return true, false, nil
}
......@@ -449,7 +448,7 @@ func updateModuleFields(ctx context.Context, s store.Storer, m *types.Module, ne
continue
}
ef.DeletedAt = nowPtr()
ef.DeletedAt = now()
err = store.UpdateComposeModuleField(ctx, s, ef)
if err != nil {
return err
......@@ -471,12 +470,12 @@ func updateModuleFields(ctx context.Context, s store.Storer, m *types.Module, ne
f.Kind = e.Kind
}
f.UpdatedAt = nowPtr()
f.UpdatedAt = now()
err = store.UpdateComposeModuleField(ctx, s, f)
} else {
f.ID = id.Next()
f.CreatedAt = *nowPtr()
f.ID = nextID()
f.CreatedAt = *now()
err = store.CreateComposeModuleField(ctx, s, f)
}
......
......@@ -293,7 +293,7 @@ func (svc namespace) handleUpdate(upd *types.Namespace) namespaceUpdateHandler {
ns.Slug = upd.Slug
ns.Meta = upd.Meta
ns.Enabled = upd.Enabled
ns.UpdatedAt = nowPtr()
ns.UpdatedAt = now()
return true, nil
}
......@@ -309,7 +309,7 @@ func (svc namespace) handleDelete(ctx context.Context, ns *types.Namespace) (boo
return false, nil
}
ns.DeletedAt = nowPtr()
ns.DeletedAt = now()
return true, nil
}
......
......@@ -409,7 +409,7 @@ func (svc page) handleUpdate(upd *types.Page) pageUpdateHandler {
p.Description = upd.Description
p.Visible = upd.Visible
p.Weight = upd.Weight
p.UpdatedAt = nowPtr()
p.UpdatedAt = now()
return true, nil
}
......@@ -425,7 +425,7 @@ func (svc page) handleDelete(ctx context.Context, ns *types.Namespace, m *types.
return false, nil
}
m.DeletedAt = nowPtr()
m.DeletedAt = now()
return true, nil
}
......
......@@ -12,7 +12,6 @@ import (
"github.com/cortezaproject/corteza-server/pkg/auth"
"github.com/cortezaproject/corteza-server/pkg/corredor"
"github.com/cortezaproject/corteza-server/pkg/eventbus"
"github.com/cortezaproject/corteza-server/pkg/id"
"github.com/cortezaproject/corteza-server/store"
"regexp"
"strconv"
......@@ -684,9 +683,9 @@ func (svc record) procCreate(ctx context.Context, s store.Storer, invokerID uint
// Reset values to new record
// to make sure nobody slips in something we do not want
new.ID = id.Next()
new.ID = nextID()
new.CreatedBy = invokerID
new.CreatedAt = *nowPtr()
new.CreatedAt = *now()
new.UpdatedAt = nil
new.UpdatedBy = 0
new.DeletedAt = nil
......@@ -738,7 +737,7 @@ func (svc record) procUpdate(ctx context.Context, s store.Storer, invokerID uint
// to make sure nobody slips in something we do not want
upd.CreatedAt = old.CreatedAt
upd.CreatedBy = old.CreatedBy
upd.UpdatedAt = nowPtr()
upd.UpdatedAt = now()
upd.UpdatedBy = invokerID
upd.DeletedAt = old.DeletedAt
upd.DeletedBy = old.DeletedBy
......@@ -805,7 +804,7 @@ func (svc record) delete(namespaceID, moduleID, recordID uint64) (del *types.Rec
}
}
del.DeletedAt = nowPtr()
del.DeletedAt = now()
del.DeletedBy = invokerID
err = store.Tx(svc.ctx, svc.store, func(ctx context.Context, s store.Storer) error {
......@@ -1193,7 +1192,7 @@ func (svc record) Iterator(f types.RecordFilter, fn eventbus.HandlerFn, action s
recordableAction = RecordActionIteratorDelete
return store.Tx(svc.ctx, svc.store, func(ctx context.Context, s store.Storer) error {
rec.DeletedAt = nowPtr()
rec.DeletedAt = now()
rec.DeletedBy = invokerID
return store.UpdateComposeRecord(ctx, s, m, rec)
})
......
......@@ -9,6 +9,7 @@ import (
"github.com/cortezaproject/corteza-server/pkg/corredor"
"github.com/cortezaproject/corteza-server/pkg/eventbus"
"github.com/cortezaproject/corteza-server/pkg/healthcheck"
"github.com/cortezaproject/corteza-server/pkg/id"
"github.com/cortezaproject/corteza-server/pkg/objstore"
"github.com/cortezaproject/corteza-server/pkg/objstore/minio"
"github.com/cortezaproject/corteza-server/pkg/objstore/plain"
......@@ -72,6 +73,17 @@ var (
DefaultSystemUser systemService.UserService
//DefaultSystemUser *systemUser
//DefaultSystemRole *systemRole
// wrapper around time.Now() that will aid service testing
now = func() *time.Time {
c := time.Now()
return &c
}
// wrapper around nextID that will aid service testing
nextID = func() uint64 {
return id.Next()
}
)
// Initializes compose-only services
......@@ -225,11 +237,6 @@ func isStale(new *time.Time, updatedAt *time.Time, createdAt time.Time) bool {
return new.Equal(createdAt)
}
func nowPtr() *time.Time {
now := time.Now()
return &now
}
// trim1st removes 1st param and returns only error
func trim1st(_ interface{}, err error) error {
return err
......
......@@ -36,8 +36,3 @@ var (
isoDaty = regexp.MustCompile(`^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}`)
hasTimezone = regexp.MustCompile(`(Z|\+\d{2}:\d{2})$`)
)
func nowPtr() *time.Time {
now := time.Now()
return &now
}
......@@ -8,7 +8,6 @@ import (
"github.com/cortezaproject/corteza-server/messaging/types"
"github.com/cortezaproject/corteza-server/pkg/actionlog"
intAuth "github.com/cortezaproject/corteza-server/pkg/auth"
"github.com/cortezaproject/corteza-server/pkg/id"
files "github.com/cortezaproject/corteza-server/pkg/objstore"
"github.com/cortezaproject/corteza-server/store"
"github.com/disintegration/imaging"
......@@ -117,7 +116,7 @@ func (svc attachment) CreateMessageAttachment(name string, size int64, fh io.Rea
}
att = &types.Attachment{
ID: id.Next(),
ID: nextID(),
OwnerID: currentUserID,
Name: strings.TrimSpace(name),
CreatedAt: *now(),
......@@ -133,7 +132,7 @@ func (svc attachment) CreateMessageAttachment(name string, size int64, fh io.Rea
}
msg := &types.Message{
ID: id.Next(),
ID: nextID(),
Attachment: att,
Message: name,
Type: types.MessageTypeAttachment,
......
......@@ -7,7 +7,6 @@ import (
"github.com/cortezaproject/corteza-server/messaging/types"
"github.com/cortezaproject/corteza-server/pkg/actionlog"
"github.com/cortezaproject/corteza-server/pkg/auth"
"github.com/cortezaproject/corteza-server/pkg/id"
"github.com/cortezaproject/corteza-server/store"
)
......@@ -317,7 +316,7 @@ func (svc *channel) Create(new *types.Channel) (ch *types.Channel, err error) {
// This is a fresh channel, just copy values
ch = &types.Channel{
ID: id.Next(),
ID: nextID(),
Name: new.Name,
Topic: new.Topic,
Type: new.Type,
......@@ -968,7 +967,7 @@ func (svc *channel) flushSystemMessages() (err error) {
}()
return svc.sysmsgs.Walk(func(msg *types.Message) error {
msg.ID = id.Next()
msg.ID = nextID()
msg.CreatedAt = *now()
if err = store.CreateMessagingMessage(svc.ctx, svc.store, msg); err != nil {
......
......@@ -5,7 +5,6 @@ import (
"fmt"
"github.com/cortezaproject/corteza-server/messaging/types"
"github.com/cortezaproject/corteza-server/pkg/auth"
"github.com/cortezaproject/corteza-server/pkg/id"
"github.com/cortezaproject/corteza-server/pkg/payload"
"github.com/cortezaproject/corteza-server/store"
"io"
......@@ -142,7 +141,7 @@ func (svc message) readableChannels(f types.MessageFilter) ([]uint64, error) {
}
func (svc message) Create(msg *types.Message) (*types.Message, error) {
msg.ID = id.Next()
msg.ID = nextID()
msg.CreatedAt = *now()
msg.Message = strings.TrimSpace(msg.Message)
......@@ -594,7 +593,7 @@ func (svc message) flag(messageID uint64, flag string, remove bool) (err error)
} else {
ff = []*types.MessageFlag{
{
ID: id.Next(),
ID: nextID(),
UserID: currentUserID,
CreatedAt: *now(),
ChannelID: msg.ChannelID,
......
......@@ -4,6 +4,7 @@ import (
"context"
"github.com/cortezaproject/corteza-server/pkg/actionlog"
"github.com/cortezaproject/corteza-server/pkg/healthcheck"
"github.com/cortezaproject/corteza-server/pkg/id"
"github.com/cortezaproject/corteza-server/pkg/objstore"
"github.com/cortezaproject/corteza-server/pkg/objstore/minio"
"github.com/cortezaproject/corteza-server/pkg/objstore/plain"
......@@ -51,6 +52,17 @@ var (
DefaultMessage MessageService
DefaultEvent EventService
DefaultCommand CommandService
// wrapper around time.Now() that will aid service testing
now = func() *time.Time {
c := time.Now()
return &c
}
// wrapper around nextID that will aid service testing
nextID = func() uint64 {
return id.Next()
}
)
func Initialize(ctx context.Context, log *zap.Logger, s store.Storer, c Config) (err error) {
......@@ -140,8 +152,3 @@ func Activate(ctx context.Context) (err error) {
func Watchers(ctx context.Context) {
DefaultPermissions.Watch(ctx)
}
func now() *time.Time {
now := time.Now()
return &now
}
......@@ -3,9 +3,9 @@ package tests
import (
"context"
"github.com/cortezaproject/corteza-server/pkg/id"
"github.com/cortezaproject/corteza-server/pkg/rand"
"github.com/cortezaproject/corteza-server/store"
"github.com/cortezaproject/corteza-server/system/types"
"github.com/cortezaproject/corteza-server/pkg/rand"
_ "github.com/joho/godotenv/autoload"
"github.com/stretchr/testify/require"
"strings"
......
......@@ -106,7 +106,7 @@ func (svc *application) Create(ctx context.Context, new *types.Application) (app
// Set new values after beforeCreate events are emitted
new.ID = nextID()
new.CreatedAt = now()
new.CreatedAt = *now()
if new.Unify == nil {
new.Unify = &types.ApplicationUnify{}
......@@ -152,7 +152,7 @@ func (svc *application) Update(ctx context.Context, upd *types.Application) (app
// Assign changed values after afterUpdate events are emitted
app.Name = upd.Name
app.Enabled = upd.Enabled
app.UpdatedAt = nowPtr()
app.UpdatedAt = now()
if upd.Unify != nil {
app.Unify = upd.Unify
......@@ -194,7 +194,7 @@ func (svc *application) Delete(ctx context.Context, ID uint64) (err error) {
return
}
app.DeletedAt = nowPtr()
app.DeletedAt = now()
if err = store.UpdateApplication(ctx, svc.store, app); err != nil {
return
}
......
......@@ -5,7 +5,6 @@ import (
"context"
"github.com/cortezaproject/corteza-server/pkg/actionlog"
intAuth "github.com/cortezaproject/corteza-server/pkg/auth"
"github.com/cortezaproject/corteza-server/pkg/id"
files "github.com/cortezaproject/corteza-server/pkg/objstore"
"github.com/cortezaproject/corteza-server/store"
"github.com/cortezaproject/corteza-server/system/types"
......@@ -108,7 +107,7 @@ func (svc attachment) DeleteByID(ID uint64) (err error) {
return err
}
att.DeletedAt = nowPtr()
att.DeletedAt = now()
aaProps.setAttachment(att)
return store.UpdateAttachment(svc.ctx, svc.store, att)
......@@ -158,7 +157,7 @@ func (svc attachment) CreateSettingsAttachment(name string, size int64, fh io.Re
}
att = &types.Attachment{
ID: id.Next(),
ID: nextID(),
OwnerID: currentUserID,
Name: strings.TrimSpace(name),
Kind: types.AttachmentKindSettings,
......
......@@ -8,7 +8,6 @@ import (
internalAuth "github.com/cortezaproject/corteza-server/pkg/auth"
"github.com/cortezaproject/corteza-server/pkg/eventbus"
"github.com/cortezaproject/corteza-server/pkg/handle"
"github.com/cortezaproject/corteza-server/pkg/id"
"github.com/cortezaproject/corteza-server/pkg/permissions"
"github.com/cortezaproject/corteza-server/pkg/rand"
"github.com/cortezaproject/corteza-server/store"
......@@ -154,7 +153,7 @@ func (svc auth) External(ctx context.Context, profile goth.User) (u *types.User,
if u.Valid() {
// Valid user, Bingo!
c.LastUsedAt = nowPtr()
c.LastUsedAt = now()
if err = store.UpdateCredentials(ctx, svc.store, c); err != nil {
return err
}
......@@ -214,8 +213,8 @@ func (svc auth) External(ctx context.Context, profile goth.User) (u *types.User,
createHandle(ctx, svc.store, u)
}
u.ID = id.Next()
u.CreatedAt = now()
u.ID = nextID()
u.CreatedAt = *now()
if err = store.CreateUser(ctx, svc.store, u); err != nil {
return err
}
......@@ -255,12 +254,12 @@ func (svc auth) External(ctx context.Context, profile goth.User) (u *types.User,
// If we got to this point, assume that user is authenticated
// but credentials need to be stored
c := &types.Credentials{
ID: id.Next(),
CreatedAt: now(),
ID: nextID(),
CreatedAt: *now(),
Kind: profile.Provider,
OwnerID: u.ID,
Credentials: profile.UserID,
LastUsedAt: nowPtr(),
LastUsedAt: now(),
}
if err = store.CreateCredentials(ctx, svc.store, c); err != nil {
......@@ -331,8 +330,8 @@ func (svc auth) InternalSignUp(ctx context.Context, input *types.User, password
return AuthErrInvalidCredentials(aam)
} else {
// Update last-used-by timestamp on matching credentials
c.LastUsedAt = nowPtr()
c.UpdatedAt = nowPtr()
c.LastUsedAt = now()
c.UpdatedAt = now()
aam.setCredentials(c)
if err = store.UpdateCredentials(ctx, svc.store, c); err != nil {
......@@ -377,7 +376,7 @@ func (svc auth) InternalSignUp(ctx context.Context, input *types.User, password
}
var nUser = &types.User{
ID: id.Next(),
ID: nextID(),
Email: input.Email,
Name: input.Name,
Username: input.Username,
......@@ -483,8 +482,8 @@ func (svc auth) InternalLogin(ctx context.Context, email string, password string
return AuthErrInvalidCredentials(aam)
} else {
// Update last-used-by timestamp on matching credentials
c.UpdatedAt = nowPtr()
c.LastUsedAt = nowPtr()
c.UpdatedAt = now()
c.LastUsedAt = now()
aam.setCredentials(c)
if err = store.UpdateCredentials(ctx, svc.store, c); err != nil {
......@@ -664,7 +663,7 @@ func (svc auth) SetPasswordCredentials(ctx context.Context, userID uint64, passw
// Mark all credentials as deleted
_ = cc.Walk(func(c *types.Credentials) error {
c.DeletedAt = nowPtr()
c.DeletedAt = now()
return nil
})
......@@ -675,8 +674,8 @@ func (svc auth) SetPasswordCredentials(ctx context.Context, userID uint64, passw
// Add new credentials with new password
c := &types.Credentials{
ID: id.Next(),
CreatedAt: now(),
ID: nextID(),
CreatedAt: *now(),
OwnerID: userID,
Kind: credentialsTypePassword,
Credentials: string(hash),
......@@ -747,7 +746,7 @@ func (svc auth) loadFromTokenAndConfirmEmail(ctx context.Context, token, tokenTy
}
u.EmailConfirmed = true
u.UpdatedAt = nowPtr()
u.UpdatedAt = now()
if err = store.UpdateUser(ctx, svc.store, u); err != nil {
return err
}
......@@ -979,15 +978,15 @@ func (svc auth) createUserToken(ctx context.Context, u *types.User, kind string)
switch kind {
case credentialsTypeAuthToken:
// 15 sec expiration for all tokens that are part of redirection
expiresAt = nowPtr().Add(time.Second * 15)
expiresAt = now().Add(time.Second * 15)
default:
// 1h expiration for all tokens send via email
expiresAt = nowPtr().Add(time.Minute * 60)
expiresAt = now().Add(time.Minute * 60)
}
c := &types.Credentials{
ID: id.Next(),
CreatedAt: now(),
ID: nextID(),
CreatedAt: *now(),
OwnerID: u.ID,
Kind: kind,
Credentials: string(rand.Bytes(credentialsTokenLength)),
......
......@@ -4,7 +4,6 @@ import (
"context"
"fmt"
"github.com/cortezaproject/corteza-server/pkg/eventbus"
"github.com/cortezaproject/corteza-server/pkg/id"
"github.com/cortezaproject/corteza-server/store"
"github.com/cortezaproject/corteza-server/store/sqlite3"
"github.com/cortezaproject/corteza-server/system/types"
......@@ -55,15 +54,15 @@ func TestAuth_External(t *testing.T) {
ctx = context.Background()
// Create some virtual user and credentials
validUser = &types.User{Email: "valid@test.cortezaproject.org", ID: id.Next(), CreatedAt: now()}
suspendedUser = &types.User{Email: "suspended@test.cortezaproject.org", ID: id.Next(), CreatedAt: now(), SuspendedAt: nowPtr()}
validUser = &types.User{Email: "valid@test.cortezaproject.org", ID: nextID(), CreatedAt: *now()}
suspendedUser = &types.User{Email: "suspended@test.cortezaproject.org", ID: nextID(), CreatedAt: *now(), SuspendedAt: now()}
freshProfileID = func() string {
return fmt.Sprintf("fresh-profile-id-%d", id.Next())
return fmt.Sprintf("fresh-profile-id-%d", nextID())
}
fooCredentials = &types.Credentials{
ID: id.Next(),
ID: nextID(),
OwnerID: validUser.ID,
Label: "credentials for foo provider",
Kind: "foo",
......@@ -72,7 +71,7 @@ func TestAuth_External(t *testing.T) {
}
barCredentials = &types.Credentials{
ID: id.Next(),
ID: nextID(),
OwnerID: validUser.ID,
Label: "credentials for bar provider",
Kind: "bar",
......@@ -146,8 +145,8 @@ func TestAuth_InternalLogin(t *testing.T) {
ctx = context.Background()
validPass = "this is a valid password !! 42"
validUser = &types.User{Email: "valid@test.cortezaproject.org", ID: id.Next(), CreatedAt: now(), EmailConfirmed: true}
suspendedUser = &types.User{Email: "suspended@test.cortezaproject.org", ID: id.Next(), CreatedAt: now(), SuspendedAt: nowPtr()}
validUser = &types.User{Email: "valid@test.cortezaproject.org", ID: nextID(), CreatedAt: *now(), EmailConfirmed: true}
suspendedUser = &types.User{Email: "suspended@test.cortezaproject.org", ID: nextID(), CreatedAt: *now(), SuspendedAt: now()}
tests = []struct {
name string
......
......@@ -4,7 +4,6 @@ import (
"context"
"github.com/cortezaproject/corteza-server/pkg/actionlog"
intAuth "github.com/cortezaproject/corteza-server/pkg/auth"
"github.com/cortezaproject/corteza-server/pkg/id"
"github.com/cortezaproject/corteza-server/store"
"github.com/cortezaproject/corteza-server/system/types"
"time"
......@@ -119,8 +118,8 @@ func (svc reminder) Create(ctx context.Context, new *types.Reminder) (r *types.R
return err
}
r.ID = id.Next()
r.CreatedAt = now()
r.ID = nextID()
r.CreatedAt = *now()
if err = store.CreateReminder(ctx, svc.store, new); err != nil {
return err
......@@ -161,7 +160,7 @@ func (svc reminder) Update(ctx context.Context, upd *types.Reminder) (r *types.R
r.Payload = upd.Payload
r.RemindAt = upd.RemindAt
r.Resource = upd.Resource
r.UpdatedAt = nowPtr()
r.UpdatedAt = now()
if err = store.UpdateReminder(ctx, svc.store, r); err != nil {
return err
......@@ -254,7 +253,7 @@ func (svc reminder) Delete(ctx context.Context, ID uint64) (err error) {
return ReminderErrNotFound()
}
r.DeletedAt = nowPtr()
r.DeletedAt = now()
raProps.setReminder(r)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment