-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made sure all the migration to slugs within the settings is complete. I think I still need to remove it from the database as its own field. Fixed an events recovery bug, where the session needs to be captured and "recreated"... aka restore the session token to the context. Along the context lines, make use of context.WithoutCancel() to continue passing the context around with all its values but in a way that can persist across the http request ending. Also made a few more things dynamic in the profile and migrated the callsign finder to the finder interface. This way it can get cached.
- Loading branch information
1 parent
993ff09
commit 4551e45
Showing
21 changed files
with
199 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package events | ||
|
||
import "time" | ||
|
||
func init() { | ||
register[MembershipRequested]("membership.requested") | ||
register[MembershipAccepted]("membership.accepted") | ||
register[MembershipDenied]("membership.denied") | ||
register[MembershipRevoked]("membership.revoked") | ||
} | ||
|
||
type ( | ||
MembershipRequested struct { | ||
Message string `json:"message"` | ||
} | ||
|
||
MembershipAccepted struct { | ||
Message string `json:"message"` | ||
} | ||
|
||
MembershipDenied struct { | ||
Until time.Time `json:"until"` | ||
Message string `json:"message"` | ||
} | ||
|
||
MembershipRevoked struct { | ||
Message string `json:"message"` | ||
} | ||
|
||
MembershipEnded struct { | ||
Message string `json:"message"` | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package models | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/ryanfaerman/netctl/internal/dao" | ||
"github.com/ryanfaerman/netctl/internal/models/finders" | ||
) | ||
|
||
func (m Callsign) FindCacheKey() string { | ||
return "callsigns" | ||
} | ||
|
||
func (m Callsign) FindCacheDuration() time.Duration { | ||
return 7 * 24 * time.Hour | ||
} | ||
|
||
func (m Callsign) Find(ctx context.Context, queries finders.QuerySet) (any, error) { | ||
var ( | ||
raws []dao.Callsign | ||
err error | ||
found []*Callsign | ||
) | ||
|
||
switch { | ||
default: | ||
return nil, finders.ErrInvalidWhere | ||
case queries.HasWhere("account_id"): | ||
accountID, ok := finders.EnforceValue[int64](queries, "account_id") | ||
if ok != nil { | ||
return nil, ok | ||
} | ||
raws, err = global.dao.FindCallsignsForAccount(ctx, accountID) | ||
|
||
} | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
found = make([]*Callsign, len(raws)) | ||
for i, raw := range raws { | ||
found[i] = &Callsign{ | ||
ID: raw.ID, | ||
Call: raw.Callsign, | ||
Class: raw.Class, | ||
Expires: raw.Expires.Time, | ||
Status: raw.Status, | ||
Latitude: raw.Latitude.Float64, | ||
Longitude: raw.Longitude.Float64, | ||
Firstname: raw.Firstname.String, | ||
Middlename: raw.Middlename.String, | ||
Lastname: raw.Lastname.String, | ||
Suffix: raw.Suffix.String, | ||
Address: raw.Address.String, | ||
City: raw.City.String, | ||
State: raw.State.String, | ||
Zip: raw.Zip.String, | ||
Country: raw.Country.String, | ||
} | ||
} | ||
|
||
return found, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.