This commit is contained in:
Daniel 2024-11-19 09:10:55 -05:00
parent 78f6df5920
commit f6cb8b4d17
7 changed files with 29 additions and 29 deletions

View file

@ -98,7 +98,7 @@ func (a *Auth) Login(ctx context.Context, username, password string) (token stri
return a.newToken(found.ID), nil
}
func (a *Auth) newToken(uid int32) string {
func (a *Auth) newToken(uid int) string {
claims := claims{
"sub": strconv.Itoa(int(uid)),
}
@ -134,7 +134,7 @@ func (a *Auth) routeRefresh(w http.ResponseWriter, r *http.Request) {
return
}
tok := a.newToken(int32(uid))
tok := a.newToken(uid)
cookie := &http.Cookie{
Name: "jwt",

View file

@ -1293,7 +1293,7 @@ func (_c *Store_GetTalkgroupsWithLearnedBySystem_Call) RunAndReturn(run func(con
}
// GetUserByID provides a mock function with given fields: ctx, id
func (_m *Store) GetUserByID(ctx context.Context, id int32) (database.User, error) {
func (_m *Store) GetUserByID(ctx context.Context, id int) (database.User, error) {
ret := _m.Called(ctx, id)
if len(ret) == 0 {
@ -1302,16 +1302,16 @@ func (_m *Store) GetUserByID(ctx context.Context, id int32) (database.User, erro
var r0 database.User
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, int32) (database.User, error)); ok {
if rf, ok := ret.Get(0).(func(context.Context, int) (database.User, error)); ok {
return rf(ctx, id)
}
if rf, ok := ret.Get(0).(func(context.Context, int32) database.User); ok {
if rf, ok := ret.Get(0).(func(context.Context, int) database.User); ok {
r0 = rf(ctx, id)
} else {
r0 = ret.Get(0).(database.User)
}
if rf, ok := ret.Get(1).(func(context.Context, int32) error); ok {
if rf, ok := ret.Get(1).(func(context.Context, int) error); ok {
r1 = rf(ctx, id)
} else {
r1 = ret.Error(1)
@ -1327,14 +1327,14 @@ type Store_GetUserByID_Call struct {
// GetUserByID is a helper method to define mock.On call
// - ctx context.Context
// - id int32
// - id int
func (_e *Store_Expecter) GetUserByID(ctx interface{}, id interface{}) *Store_GetUserByID_Call {
return &Store_GetUserByID_Call{Call: _e.mock.On("GetUserByID", ctx, id)}
}
func (_c *Store_GetUserByID_Call) Run(run func(ctx context.Context, id int32)) *Store_GetUserByID_Call {
func (_c *Store_GetUserByID_Call) Run(run func(ctx context.Context, id int)) *Store_GetUserByID_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(int32))
run(args[0].(context.Context), args[1].(int))
})
return _c
}
@ -1344,13 +1344,13 @@ func (_c *Store_GetUserByID_Call) Return(_a0 database.User, _a1 error) *Store_Ge
return _c
}
func (_c *Store_GetUserByID_Call) RunAndReturn(run func(context.Context, int32) (database.User, error)) *Store_GetUserByID_Call {
func (_c *Store_GetUserByID_Call) RunAndReturn(run func(context.Context, int) (database.User, error)) *Store_GetUserByID_Call {
_c.Call.Return(run)
return _c
}
// GetUserByUID provides a mock function with given fields: ctx, id
func (_m *Store) GetUserByUID(ctx context.Context, id int32) (database.User, error) {
func (_m *Store) GetUserByUID(ctx context.Context, id int) (database.User, error) {
ret := _m.Called(ctx, id)
if len(ret) == 0 {
@ -1359,16 +1359,16 @@ func (_m *Store) GetUserByUID(ctx context.Context, id int32) (database.User, err
var r0 database.User
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, int32) (database.User, error)); ok {
if rf, ok := ret.Get(0).(func(context.Context, int) (database.User, error)); ok {
return rf(ctx, id)
}
if rf, ok := ret.Get(0).(func(context.Context, int32) database.User); ok {
if rf, ok := ret.Get(0).(func(context.Context, int) database.User); ok {
r0 = rf(ctx, id)
} else {
r0 = ret.Get(0).(database.User)
}
if rf, ok := ret.Get(1).(func(context.Context, int32) error); ok {
if rf, ok := ret.Get(1).(func(context.Context, int) error); ok {
r1 = rf(ctx, id)
} else {
r1 = ret.Error(1)
@ -1384,14 +1384,14 @@ type Store_GetUserByUID_Call struct {
// GetUserByUID is a helper method to define mock.On call
// - ctx context.Context
// - id int32
// - id int
func (_e *Store_Expecter) GetUserByUID(ctx interface{}, id interface{}) *Store_GetUserByUID_Call {
return &Store_GetUserByUID_Call{Call: _e.mock.On("GetUserByUID", ctx, id)}
}
func (_c *Store_GetUserByUID_Call) Run(run func(ctx context.Context, id int32)) *Store_GetUserByUID_Call {
func (_c *Store_GetUserByUID_Call) Run(run func(ctx context.Context, id int)) *Store_GetUserByUID_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(int32))
run(args[0].(context.Context), args[1].(int))
})
return _c
}
@ -1401,7 +1401,7 @@ func (_c *Store_GetUserByUID_Call) Return(_a0 database.User, _a1 error) *Store_G
return _c
}
func (_c *Store_GetUserByUID_Call) RunAndReturn(run func(context.Context, int32) (database.User, error)) *Store_GetUserByUID_Call {
func (_c *Store_GetUserByUID_Call) RunAndReturn(run func(context.Context, int) (database.User, error)) *Store_GetUserByUID_Call {
_c.Call.Return(run)
return _c
}

View file

@ -26,7 +26,7 @@ type Alert struct {
}
type ApiKey struct {
ID int32 `json:"id"`
ID int `json:"id"`
Owner int `json:"owner"`
CreatedAt time.Time `json:"created_at"`
Expires pgtype.Timestamp `json:"expires"`
@ -109,7 +109,7 @@ type TalkgroupsLearned struct {
}
type User struct {
ID int32 `json:"id"`
ID int `json:"id"`
Username string `json:"username"`
Password string `json:"password"`
Email string `json:"email"`

View file

@ -31,8 +31,8 @@ type Querier interface {
GetTalkgroupsWithAnyTags(ctx context.Context, tags []string) ([]GetTalkgroupsWithAnyTagsRow, error)
GetTalkgroupsWithLearned(ctx context.Context) ([]GetTalkgroupsWithLearnedRow, error)
GetTalkgroupsWithLearnedBySystem(ctx context.Context, system int32) ([]GetTalkgroupsWithLearnedBySystemRow, error)
GetUserByID(ctx context.Context, id int32) (User, error)
GetUserByUID(ctx context.Context, id int32) (User, error)
GetUserByID(ctx context.Context, id int) (User, error)
GetUserByUID(ctx context.Context, id int) (User, error)
GetUserByUsername(ctx context.Context, username string) (User, error)
GetUsers(ctx context.Context) ([]User, error)
SetCallTranscript(ctx context.Context, iD uuid.UUID, transcript *string) error

View file

@ -113,7 +113,7 @@ SELECT id, username, password, email, is_admin, prefs FROM users
WHERE id = $1 LIMIT 1
`
func (q *Queries) GetUserByID(ctx context.Context, id int32) (User, error) {
func (q *Queries) GetUserByID(ctx context.Context, id int) (User, error) {
row := q.db.QueryRow(ctx, getUserByID, id)
var i User
err := row.Scan(
@ -132,7 +132,7 @@ SELECT id, username, password, email, is_admin, prefs FROM users
WHERE id = $1 LIMIT 1
`
func (q *Queries) GetUserByUID(ctx context.Context, id int32) (User, error) {
func (q *Queries) GetUserByUID(ctx context.Context, id int) (User, error) {
row := q.db.QueryRow(ctx, getUserByUID, id)
var i User
err := row.Scan(

View file

@ -44,21 +44,20 @@ func NewRelayManager(s Sinks, cfgs []config.Relay) (*RelayManager, error) {
}
for i, cfg := range cfgs {
rs, err := rm.newRelay(cfg)
rs, err := rm.newRelay(i, cfg)
if err != nil {
return nil, err
}
rm.relays = append(rm.relays, rs)
sinkName := fmt.Sprintf("relay%d:%s", i, rs.url.Host)
s.Register(sinkName, rs, cfg.Required)
s.Register(rs.Name, rs, cfg.Required)
}
return rm, nil
}
func (rs *RelayManager) newRelay(cfg config.Relay) (*Relay, error) {
func (rs *RelayManager) newRelay(idx int, cfg config.Relay) (*Relay, error) {
u, err := url.Parse(cfg.URL)
if err != nil {
return nil, err
@ -71,6 +70,7 @@ func (rs *RelayManager) newRelay(cfg config.Relay) (*Relay, error) {
u = u.JoinPath("/api/call-upload")
return &Relay{
Name: fmt.Sprintf("relay%d:%s", idx, u.Host),
Relay: cfg,
url: u,
mgr: rs,

View file

@ -36,7 +36,7 @@ CREATE TABLE IF NOT EXISTS talkgroups(
alert BOOLEAN NOT NULL DEFAULT 'true',
alert_config JSONB,
weight REAL NOT NULL DEFAULT 1.0,
learned BOOLEAN,
learned BOOLEAN NOT NULL DEFAULT FALSE,
UNIQUE (system_id, tgid)
);