+4
-43
appview/db/registration.go
+4
-43
appview/db/registration.go
···
5
"fmt"
6
"strings"
7
"time"
8
-
)
9
-
10
-
// Registration represents a knot registration. Knot would've been a better
11
-
// name but we're stuck with this for historical reasons.
12
-
type Registration struct {
13
-
Id int64
14
-
Domain string
15
-
ByDid string
16
-
Created *time.Time
17
-
Registered *time.Time
18
-
NeedsUpgrade bool
19
-
}
20
21
-
func (r *Registration) Status() Status {
22
-
if r.NeedsUpgrade {
23
-
return NeedsUpgrade
24
-
} else if r.Registered != nil {
25
-
return Registered
26
-
} else {
27
-
return Pending
28
-
}
29
-
}
30
-
31
-
func (r *Registration) IsRegistered() bool {
32
-
return r.Status() == Registered
33
-
}
34
-
35
-
func (r *Registration) IsNeedsUpgrade() bool {
36
-
return r.Status() == NeedsUpgrade
37
-
}
38
-
39
-
func (r *Registration) IsPending() bool {
40
-
return r.Status() == Pending
41
-
}
42
-
43
-
type Status uint32
44
-
45
-
const (
46
-
Registered Status = iota
47
-
Pending
48
-
NeedsUpgrade
49
)
50
51
-
func GetRegistrations(e Execer, filters ...filter) ([]Registration, error) {
52
-
var registrations []Registration
53
54
var conditions []string
55
var args []any
···
81
var createdAt string
82
var registeredAt sql.Null[string]
83
var needsUpgrade int
84
-
var reg Registration
85
86
err = rows.Scan(®.Id, ®.Domain, ®.ByDid, &createdAt, ®isteredAt, &needsUpgrade)
87
if err != nil {
···
5
"fmt"
6
"strings"
7
"time"
8
9
+
"tangled.org/core/appview/models"
10
)
11
12
+
func GetRegistrations(e Execer, filters ...filter) ([]models.Registration, error) {
13
+
var registrations []models.Registration
14
15
var conditions []string
16
var args []any
···
42
var createdAt string
43
var registeredAt sql.Null[string]
44
var needsUpgrade int
45
+
var reg models.Registration
46
47
err = rows.Scan(®.Id, ®.Domain, ®.ByDid, &createdAt, ®isteredAt, &needsUpgrade)
48
if err != nil {
+44
appview/models/registration.go
+44
appview/models/registration.go
···
···
1
+
package models
2
+
3
+
import "time"
4
+
5
+
// Registration represents a knot registration. Knot would've been a better
6
+
// name but we're stuck with this for historical reasons.
7
+
type Registration struct {
8
+
Id int64
9
+
Domain string
10
+
ByDid string
11
+
Created *time.Time
12
+
Registered *time.Time
13
+
NeedsUpgrade bool
14
+
}
15
+
16
+
func (r *Registration) Status() Status {
17
+
if r.NeedsUpgrade {
18
+
return NeedsUpgrade
19
+
} else if r.Registered != nil {
20
+
return Registered
21
+
} else {
22
+
return Pending
23
+
}
24
+
}
25
+
26
+
func (r *Registration) IsRegistered() bool {
27
+
return r.Status() == Registered
28
+
}
29
+
30
+
func (r *Registration) IsNeedsUpgrade() bool {
31
+
return r.Status() == NeedsUpgrade
32
+
}
33
+
34
+
func (r *Registration) IsPending() bool {
35
+
return r.Status() == Pending
36
+
}
37
+
38
+
type Status uint32
39
+
40
+
const (
41
+
Registered Status = iota
42
+
Pending
43
+
NeedsUpgrade
44
+
)
+4
-4
appview/pages/pages.go
+4
-4
appview/pages/pages.go
···
324
}
325
326
type UpgradeBannerParams struct {
327
-
Registrations []db.Registration
328
Spindles []db.Spindle
329
}
330
···
334
335
type KnotsParams struct {
336
LoggedInUser *oauth.User
337
-
Registrations []db.Registration
338
}
339
340
func (p *Pages) Knots(w io.Writer, params KnotsParams) error {
···
343
344
type KnotParams struct {
345
LoggedInUser *oauth.User
346
-
Registration *db.Registration
347
Members []string
348
Repos map[string][]models.Repo
349
IsOwner bool
···
354
}
355
356
type KnotListingParams struct {
357
-
*db.Registration
358
}
359
360
func (p *Pages) KnotListing(w io.Writer, params KnotListingParams) error {
···
324
}
325
326
type UpgradeBannerParams struct {
327
+
Registrations []models.Registration
328
Spindles []db.Spindle
329
}
330
···
334
335
type KnotsParams struct {
336
LoggedInUser *oauth.User
337
+
Registrations []models.Registration
338
}
339
340
func (p *Pages) Knots(w io.Writer, params KnotsParams) error {
···
343
344
type KnotParams struct {
345
LoggedInUser *oauth.User
346
+
Registration *models.Registration
347
Members []string
348
Repos map[string][]models.Repo
349
IsOwner bool
···
354
}
355
356
type KnotListingParams struct {
357
+
*models.Registration
358
}
359
360
func (p *Pages) KnotListing(w io.Writer, params KnotListingParams) error {