mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-04 04:23:16 +00:00
refactor: update visibilities
This commit is contained in:
@ -7,22 +7,20 @@ import (
|
||||
)
|
||||
|
||||
type UpdateCollection struct {
|
||||
ID int32
|
||||
|
||||
RowStatus *RowStatus
|
||||
ID int32
|
||||
Name *string
|
||||
Link *string
|
||||
Title *string
|
||||
Description *string
|
||||
ShortcutIDs []int32
|
||||
Visibility *Visibility
|
||||
Visibility *storepb.Visibility
|
||||
}
|
||||
|
||||
type FindCollection struct {
|
||||
ID *int32
|
||||
CreatorID *int32
|
||||
Name *string
|
||||
VisibilityList []Visibility
|
||||
VisibilityList []storepb.Visibility
|
||||
}
|
||||
|
||||
type DeleteCollection struct {
|
||||
|
@ -4,26 +4,6 @@ import (
|
||||
storepb "github.com/yourselfhosted/slash/proto/gen/store"
|
||||
)
|
||||
|
||||
// RowStatus is the status for a row.
|
||||
type RowStatus string
|
||||
|
||||
const (
|
||||
// Normal is the status for a normal row.
|
||||
Normal RowStatus = "NORMAL"
|
||||
// Archived is the status for an archived row.
|
||||
Archived RowStatus = "ARCHIVED"
|
||||
)
|
||||
|
||||
func (e RowStatus) String() string {
|
||||
switch e {
|
||||
case Normal:
|
||||
return "NORMAL"
|
||||
case Archived:
|
||||
return "ARCHIVED"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func ConvertRowStatusStringToStorepb(status string) storepb.RowStatus {
|
||||
switch status {
|
||||
case "NORMAL":
|
||||
@ -34,26 +14,12 @@ func ConvertRowStatusStringToStorepb(status string) storepb.RowStatus {
|
||||
return storepb.RowStatus_ROW_STATUS_UNSPECIFIED
|
||||
}
|
||||
|
||||
// Visibility is the type of a visibility.
|
||||
type Visibility string
|
||||
|
||||
const (
|
||||
// VisibilityPublic is the PUBLIC visibility.
|
||||
VisibilityPublic Visibility = "PUBLIC"
|
||||
// VisibilityWorkspace is the WORKSPACE visibility.
|
||||
VisibilityWorkspace Visibility = "WORKSPACE"
|
||||
// VisibilityPrivate is the PRIVATE visibility.
|
||||
VisibilityPrivate Visibility = "PRIVATE"
|
||||
)
|
||||
|
||||
func (e Visibility) String() string {
|
||||
switch e {
|
||||
case VisibilityPublic:
|
||||
return "PUBLIC"
|
||||
case VisibilityWorkspace:
|
||||
return "WORKSPACE"
|
||||
case VisibilityPrivate:
|
||||
return "PRIVATE"
|
||||
func ConvertVisibilityStringToStorepb(visibility string) storepb.Visibility {
|
||||
switch visibility {
|
||||
case "PRIVATE", "WORKSPACE":
|
||||
return storepb.Visibility_WORKSPACE
|
||||
case "PUBLIC":
|
||||
return storepb.Visibility_PUBLIC
|
||||
}
|
||||
return "PRIVATE"
|
||||
return storepb.Visibility_VISIBILITY_UNSPECIFIED
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ func (d *DB) UpdateCollection(ctx context.Context, update *store.UpdateCollectio
|
||||
collection.ShortcutIds = append(collection.ShortcutIds, id.Int32)
|
||||
}
|
||||
}
|
||||
collection.Visibility = convertVisibilityStringToStorepb(visibility)
|
||||
collection.Visibility = store.ConvertVisibilityStringToStorepb(visibility)
|
||||
return collection, nil
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ func (d *DB) ListCollections(ctx context.Context, find *store.FindCollection) ([
|
||||
collection.ShortcutIds = append(collection.ShortcutIds, id.Int32)
|
||||
}
|
||||
}
|
||||
collection.Visibility = storepb.Visibility(storepb.Visibility_value[visibility])
|
||||
collection.Visibility = store.ConvertVisibilityStringToStorepb(visibility)
|
||||
list = append(list, collection)
|
||||
}
|
||||
|
||||
|
@ -27,28 +27,21 @@ func (d *DB) CreateShortcut(ctx context.Context, create *storepb.Shortcut) (*sto
|
||||
stmt := fmt.Sprintf(`
|
||||
INSERT INTO shortcut (%s)
|
||||
VALUES (%s)
|
||||
RETURNING id, created_ts, updated_ts, row_status
|
||||
RETURNING id, created_ts, updated_ts
|
||||
`, strings.Join(set, ","), placeholders(len(args)))
|
||||
|
||||
var rowStatus string
|
||||
if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(
|
||||
&create.Id,
|
||||
&create.CreatedTs,
|
||||
&create.UpdatedTs,
|
||||
&rowStatus,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
create.RowStatus = store.ConvertRowStatusStringToStorepb(rowStatus)
|
||||
shortcut := create
|
||||
return shortcut, nil
|
||||
}
|
||||
|
||||
func (d *DB) UpdateShortcut(ctx context.Context, update *store.UpdateShortcut) (*storepb.Shortcut, error) {
|
||||
set, args := []string{}, []any{}
|
||||
if update.RowStatus != nil {
|
||||
set, args = append(set, fmt.Sprintf("row_status = $%d", len(args)+1)), append(args, update.RowStatus.String())
|
||||
}
|
||||
if update.Name != nil {
|
||||
set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *update.Name)
|
||||
}
|
||||
@ -70,7 +63,7 @@ func (d *DB) UpdateShortcut(ctx context.Context, update *store.UpdateShortcut) (
|
||||
if update.OpenGraphMetadata != nil {
|
||||
openGraphMetadataBytes, err := protojson.Marshal(update.OpenGraphMetadata)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Failed to marshal activity payload")
|
||||
return nil, errors.Wrap(err, "failed to marshal activity payload")
|
||||
}
|
||||
set, args = append(set, fmt.Sprintf("og_metadata = $%d", len(args)+1)), append(args, string(openGraphMetadataBytes))
|
||||
}
|
||||
@ -83,17 +76,16 @@ func (d *DB) UpdateShortcut(ctx context.Context, update *store.UpdateShortcut) (
|
||||
UPDATE shortcut
|
||||
SET %s
|
||||
WHERE id = $%d
|
||||
RETURNING id, creator_id, created_ts, updated_ts, row_status, name, link, title, description, visibility, tag, og_metadata
|
||||
RETURNING id, creator_id, created_ts, updated_ts, name, link, title, description, visibility, tag, og_metadata
|
||||
`, strings.Join(set, ","), len(args))
|
||||
|
||||
shortcut := &storepb.Shortcut{}
|
||||
var rowStatus, visibility, tags, openGraphMetadataString string
|
||||
var visibility, tags, openGraphMetadataString string
|
||||
if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(
|
||||
&shortcut.Id,
|
||||
&shortcut.CreatorId,
|
||||
&shortcut.CreatedTs,
|
||||
&shortcut.UpdatedTs,
|
||||
&rowStatus,
|
||||
&shortcut.Name,
|
||||
&shortcut.Link,
|
||||
&shortcut.Title,
|
||||
@ -104,8 +96,7 @@ func (d *DB) UpdateShortcut(ctx context.Context, update *store.UpdateShortcut) (
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
shortcut.RowStatus = store.ConvertRowStatusStringToStorepb(rowStatus)
|
||||
shortcut.Visibility = convertVisibilityStringToStorepb(visibility)
|
||||
shortcut.Visibility = store.ConvertVisibilityStringToStorepb(visibility)
|
||||
shortcut.Tags = filterTags(strings.Split(tags, " "))
|
||||
var ogMetadata storepb.OpenGraphMetadata
|
||||
if err := protojson.Unmarshal([]byte(openGraphMetadataString), &ogMetadata); err != nil {
|
||||
@ -123,9 +114,6 @@ func (d *DB) ListShortcuts(ctx context.Context, find *store.FindShortcut) ([]*st
|
||||
if v := find.CreatorID; v != nil {
|
||||
where, args = append(where, fmt.Sprintf("creator_id = %s", placeholder(len(args)+1))), append(args, *v)
|
||||
}
|
||||
if v := find.RowStatus; v != nil {
|
||||
where, args = append(where, fmt.Sprintf("row_status = %s", placeholder(len(args)+1))), append(args, *v)
|
||||
}
|
||||
if v := find.Name; v != nil {
|
||||
where, args = append(where, fmt.Sprintf("name = %s", placeholder(len(args)+1))), append(args, *v)
|
||||
}
|
||||
@ -147,7 +135,6 @@ func (d *DB) ListShortcuts(ctx context.Context, find *store.FindShortcut) ([]*st
|
||||
creator_id,
|
||||
created_ts,
|
||||
updated_ts,
|
||||
row_status,
|
||||
name,
|
||||
link,
|
||||
title,
|
||||
@ -167,13 +154,12 @@ func (d *DB) ListShortcuts(ctx context.Context, find *store.FindShortcut) ([]*st
|
||||
list := make([]*storepb.Shortcut, 0)
|
||||
for rows.Next() {
|
||||
shortcut := &storepb.Shortcut{}
|
||||
var rowStatus, visibility, tags, openGraphMetadataString string
|
||||
var visibility, tags, openGraphMetadataString string
|
||||
if err := rows.Scan(
|
||||
&shortcut.Id,
|
||||
&shortcut.CreatorId,
|
||||
&shortcut.CreatedTs,
|
||||
&shortcut.UpdatedTs,
|
||||
&rowStatus,
|
||||
&shortcut.Name,
|
||||
&shortcut.Link,
|
||||
&shortcut.Title,
|
||||
@ -184,8 +170,7 @@ func (d *DB) ListShortcuts(ctx context.Context, find *store.FindShortcut) ([]*st
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
shortcut.RowStatus = store.ConvertRowStatusStringToStorepb(rowStatus)
|
||||
shortcut.Visibility = storepb.Visibility(storepb.Visibility_value[visibility])
|
||||
shortcut.Visibility = store.ConvertVisibilityStringToStorepb(visibility)
|
||||
shortcut.Tags = filterTags(strings.Split(tags, " "))
|
||||
var ogMetadata storepb.OpenGraphMetadata
|
||||
if err := protojson.Unmarshal([]byte(openGraphMetadataString), &ogMetadata); err != nil {
|
||||
@ -215,7 +200,3 @@ func filterTags(tags []string) []string {
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func convertVisibilityStringToStorepb(visibility string) storepb.Visibility {
|
||||
return storepb.Visibility(storepb.Visibility_value[visibility])
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ func (d *DB) CreateUser(ctx context.Context, create *store.User) (*store.User, e
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING id, created_ts, updated_ts, row_status
|
||||
`
|
||||
var rowStatus string
|
||||
if err := d.db.QueryRowContext(ctx, stmt,
|
||||
create.Email,
|
||||
create.Nickname,
|
||||
@ -28,19 +29,20 @@ func (d *DB) CreateUser(ctx context.Context, create *store.User) (*store.User, e
|
||||
&create.ID,
|
||||
&create.CreatedTs,
|
||||
&create.UpdatedTs,
|
||||
&create.RowStatus,
|
||||
&rowStatus,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
user := create
|
||||
user.RowStatus = store.ConvertRowStatusStringToStorepb(rowStatus)
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func (d *DB) UpdateUser(ctx context.Context, update *store.UpdateUser) (*store.User, error) {
|
||||
set, args := []string{}, []any{}
|
||||
if v := update.RowStatus; v != nil {
|
||||
set, args = append(set, "row_status = "+placeholder(len(args)+1)), append(args, *v)
|
||||
set, args = append(set, "row_status = "+placeholder(len(args)+1)), append(args, v.String())
|
||||
}
|
||||
if v := update.Email; v != nil {
|
||||
set, args = append(set, "email = "+placeholder(len(args)+1)), append(args, *v)
|
||||
@ -66,11 +68,12 @@ func (d *DB) UpdateUser(ctx context.Context, update *store.UpdateUser) (*store.U
|
||||
`
|
||||
args = append(args, update.ID)
|
||||
user := &store.User{}
|
||||
var rowStatus string
|
||||
if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(
|
||||
&user.ID,
|
||||
&user.CreatedTs,
|
||||
&user.UpdatedTs,
|
||||
&user.RowStatus,
|
||||
&rowStatus,
|
||||
&user.Email,
|
||||
&user.Nickname,
|
||||
&user.PasswordHash,
|
||||
@ -79,6 +82,7 @@ func (d *DB) UpdateUser(ctx context.Context, update *store.UpdateUser) (*store.U
|
||||
return nil, err
|
||||
}
|
||||
|
||||
user.RowStatus = store.ConvertRowStatusStringToStorepb(rowStatus)
|
||||
return user, nil
|
||||
}
|
||||
|
||||
@ -124,11 +128,12 @@ func (d *DB) ListUsers(ctx context.Context, find *store.FindUser) ([]*store.User
|
||||
list := make([]*store.User, 0)
|
||||
for rows.Next() {
|
||||
user := &store.User{}
|
||||
var rowStatus string
|
||||
if err := rows.Scan(
|
||||
&user.ID,
|
||||
&user.CreatedTs,
|
||||
&user.UpdatedTs,
|
||||
&user.RowStatus,
|
||||
&rowStatus,
|
||||
&user.Email,
|
||||
&user.Nickname,
|
||||
&user.PasswordHash,
|
||||
@ -136,6 +141,7 @@ func (d *DB) ListUsers(ctx context.Context, find *store.FindUser) ([]*store.User
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
user.RowStatus = store.ConvertRowStatusStringToStorepb(rowStatus)
|
||||
list = append(list, user)
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ func (d *DB) UpdateCollection(ctx context.Context, update *store.UpdateCollectio
|
||||
collection.ShortcutIds = append(collection.ShortcutIds, shortcutID)
|
||||
}
|
||||
}
|
||||
collection.Visibility = convertVisibilityStringToStorepb(visibility)
|
||||
collection.Visibility = store.ConvertVisibilityStringToStorepb(visibility)
|
||||
return collection, nil
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ func (d *DB) ListCollections(ctx context.Context, find *store.FindCollection) ([
|
||||
collection.ShortcutIds = append(collection.ShortcutIds, shortcutID)
|
||||
}
|
||||
}
|
||||
collection.Visibility = storepb.Visibility(storepb.Visibility_value[visibility])
|
||||
collection.Visibility = store.ConvertVisibilityStringToStorepb(visibility)
|
||||
list = append(list, collection)
|
||||
}
|
||||
|
||||
@ -189,6 +189,5 @@ func vacuumCollection(ctx context.Context, tx *sql.Tx) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -32,27 +32,21 @@ func (d *DB) CreateShortcut(ctx context.Context, create *storepb.Shortcut) (*sto
|
||||
` + strings.Join(set, ", ") + `
|
||||
)
|
||||
VALUES (` + strings.Join(placeholder, ",") + `)
|
||||
RETURNING id, created_ts, updated_ts, row_status
|
||||
RETURNING id, created_ts, updated_ts
|
||||
`
|
||||
var rowStatus string
|
||||
if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(
|
||||
&create.Id,
|
||||
&create.CreatedTs,
|
||||
&create.UpdatedTs,
|
||||
&rowStatus,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
create.RowStatus = store.ConvertRowStatusStringToStorepb(rowStatus)
|
||||
shortcut := create
|
||||
return shortcut, nil
|
||||
}
|
||||
|
||||
func (d *DB) UpdateShortcut(ctx context.Context, update *store.UpdateShortcut) (*storepb.Shortcut, error) {
|
||||
set, args := []string{}, []any{}
|
||||
if update.RowStatus != nil {
|
||||
set, args = append(set, "row_status = ?"), append(args, update.RowStatus.String())
|
||||
}
|
||||
if update.Name != nil {
|
||||
set, args = append(set, "name = ?"), append(args, *update.Name)
|
||||
}
|
||||
@ -89,16 +83,15 @@ func (d *DB) UpdateShortcut(ctx context.Context, update *store.UpdateShortcut) (
|
||||
` + strings.Join(set, ", ") + `
|
||||
WHERE
|
||||
id = ?
|
||||
RETURNING id, creator_id, created_ts, updated_ts, row_status, name, link, title, description, visibility, tag, og_metadata
|
||||
RETURNING id, creator_id, created_ts, updated_ts, name, link, title, description, visibility, tag, og_metadata
|
||||
`
|
||||
shortcut := &storepb.Shortcut{}
|
||||
var rowStatus, visibility, tags, openGraphMetadataString string
|
||||
var visibility, tags, openGraphMetadataString string
|
||||
if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(
|
||||
&shortcut.Id,
|
||||
&shortcut.CreatorId,
|
||||
&shortcut.CreatedTs,
|
||||
&shortcut.UpdatedTs,
|
||||
&rowStatus,
|
||||
&shortcut.Name,
|
||||
&shortcut.Link,
|
||||
&shortcut.Title,
|
||||
@ -109,8 +102,7 @@ func (d *DB) UpdateShortcut(ctx context.Context, update *store.UpdateShortcut) (
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
shortcut.RowStatus = store.ConvertRowStatusStringToStorepb(rowStatus)
|
||||
shortcut.Visibility = convertVisibilityStringToStorepb(visibility)
|
||||
shortcut.Visibility = store.ConvertVisibilityStringToStorepb(visibility)
|
||||
shortcut.Tags = filterTags(strings.Split(tags, " "))
|
||||
var ogMetadata storepb.OpenGraphMetadata
|
||||
if err := protojson.Unmarshal([]byte(openGraphMetadataString), &ogMetadata); err != nil {
|
||||
@ -128,9 +120,6 @@ func (d *DB) ListShortcuts(ctx context.Context, find *store.FindShortcut) ([]*st
|
||||
if v := find.CreatorID; v != nil {
|
||||
where, args = append(where, "creator_id = ?"), append(args, *v)
|
||||
}
|
||||
if v := find.RowStatus; v != nil {
|
||||
where, args = append(where, "row_status = ?"), append(args, *v)
|
||||
}
|
||||
if v := find.Name; v != nil {
|
||||
where, args = append(where, "name = ?"), append(args, *v)
|
||||
}
|
||||
@ -138,7 +127,7 @@ func (d *DB) ListShortcuts(ctx context.Context, find *store.FindShortcut) ([]*st
|
||||
list := []string{}
|
||||
for _, visibility := range v {
|
||||
list = append(list, fmt.Sprintf("$%d", len(args)+1))
|
||||
args = append(args, visibility)
|
||||
args = append(args, visibility.String())
|
||||
}
|
||||
where = append(where, fmt.Sprintf("visibility in (%s)", strings.Join(list, ",")))
|
||||
}
|
||||
@ -152,7 +141,6 @@ func (d *DB) ListShortcuts(ctx context.Context, find *store.FindShortcut) ([]*st
|
||||
creator_id,
|
||||
created_ts,
|
||||
updated_ts,
|
||||
row_status,
|
||||
name,
|
||||
link,
|
||||
title,
|
||||
@ -173,13 +161,12 @@ func (d *DB) ListShortcuts(ctx context.Context, find *store.FindShortcut) ([]*st
|
||||
list := make([]*storepb.Shortcut, 0)
|
||||
for rows.Next() {
|
||||
shortcut := &storepb.Shortcut{}
|
||||
var rowStatus, visibility, tags, openGraphMetadataString string
|
||||
var visibility, tags, openGraphMetadataString string
|
||||
if err := rows.Scan(
|
||||
&shortcut.Id,
|
||||
&shortcut.CreatorId,
|
||||
&shortcut.CreatedTs,
|
||||
&shortcut.UpdatedTs,
|
||||
&rowStatus,
|
||||
&shortcut.Name,
|
||||
&shortcut.Link,
|
||||
&shortcut.Title,
|
||||
@ -190,8 +177,7 @@ func (d *DB) ListShortcuts(ctx context.Context, find *store.FindShortcut) ([]*st
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
shortcut.RowStatus = store.ConvertRowStatusStringToStorepb(rowStatus)
|
||||
shortcut.Visibility = storepb.Visibility(storepb.Visibility_value[visibility])
|
||||
shortcut.Visibility = store.ConvertVisibilityStringToStorepb(visibility)
|
||||
shortcut.Tags = filterTags(strings.Split(tags, " "))
|
||||
var ogMetadata storepb.OpenGraphMetadata
|
||||
if err := protojson.Unmarshal([]byte(openGraphMetadataString), &ogMetadata); err != nil {
|
||||
@ -234,7 +220,3 @@ func filterTags(tags []string) []string {
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func convertVisibilityStringToStorepb(visibility string) storepb.Visibility {
|
||||
return storepb.Visibility(storepb.Visibility_value[visibility])
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ func (d *DB) CreateUser(ctx context.Context, create *store.User) (*store.User, e
|
||||
VALUES (?, ?, ?, ?)
|
||||
RETURNING id, created_ts, updated_ts, row_status
|
||||
`
|
||||
var rowStatus string
|
||||
if err := d.db.QueryRowContext(ctx, stmt,
|
||||
create.Email,
|
||||
create.Nickname,
|
||||
@ -28,19 +29,20 @@ func (d *DB) CreateUser(ctx context.Context, create *store.User) (*store.User, e
|
||||
&create.ID,
|
||||
&create.CreatedTs,
|
||||
&create.UpdatedTs,
|
||||
&create.RowStatus,
|
||||
&rowStatus,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
user := create
|
||||
user.RowStatus = store.ConvertRowStatusStringToStorepb(rowStatus)
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func (d *DB) UpdateUser(ctx context.Context, update *store.UpdateUser) (*store.User, error) {
|
||||
set, args := []string{}, []any{}
|
||||
if v := update.RowStatus; v != nil {
|
||||
set, args = append(set, "row_status = ?"), append(args, *v)
|
||||
set, args = append(set, "row_status = ?"), append(args, v.String())
|
||||
}
|
||||
if v := update.Email; v != nil {
|
||||
set, args = append(set, "email = ?"), append(args, *v)
|
||||
@ -67,11 +69,12 @@ func (d *DB) UpdateUser(ctx context.Context, update *store.UpdateUser) (*store.U
|
||||
`
|
||||
args = append(args, update.ID)
|
||||
user := &store.User{}
|
||||
var rowStatus string
|
||||
if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(
|
||||
&user.ID,
|
||||
&user.CreatedTs,
|
||||
&user.UpdatedTs,
|
||||
&user.RowStatus,
|
||||
&rowStatus,
|
||||
&user.Email,
|
||||
&user.Nickname,
|
||||
&user.PasswordHash,
|
||||
@ -79,7 +82,7 @@ func (d *DB) UpdateUser(ctx context.Context, update *store.UpdateUser) (*store.U
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
user.RowStatus = store.ConvertRowStatusStringToStorepb(rowStatus)
|
||||
return user, nil
|
||||
}
|
||||
|
||||
@ -125,11 +128,12 @@ func (d *DB) ListUsers(ctx context.Context, find *store.FindUser) ([]*store.User
|
||||
list := make([]*store.User, 0)
|
||||
for rows.Next() {
|
||||
user := &store.User{}
|
||||
var rowStatus string
|
||||
if err := rows.Scan(
|
||||
&user.ID,
|
||||
&user.CreatedTs,
|
||||
&user.UpdatedTs,
|
||||
&user.RowStatus,
|
||||
&rowStatus,
|
||||
&user.Email,
|
||||
&user.Nickname,
|
||||
&user.PasswordHash,
|
||||
@ -137,6 +141,7 @@ func (d *DB) ListUsers(ctx context.Context, find *store.FindUser) ([]*store.User
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
user.RowStatus = store.ConvertRowStatusStringToStorepb(rowStatus)
|
||||
list = append(list, user)
|
||||
}
|
||||
|
||||
|
@ -9,12 +9,11 @@ import (
|
||||
type UpdateShortcut struct {
|
||||
ID int32
|
||||
|
||||
RowStatus *RowStatus
|
||||
Name *string
|
||||
Link *string
|
||||
Title *string
|
||||
Description *string
|
||||
Visibility *Visibility
|
||||
Visibility *storepb.Visibility
|
||||
Tag *string
|
||||
OpenGraphMetadata *storepb.OpenGraphMetadata
|
||||
}
|
||||
@ -22,9 +21,8 @@ type UpdateShortcut struct {
|
||||
type FindShortcut struct {
|
||||
ID *int32
|
||||
CreatorID *int32
|
||||
RowStatus *RowStatus
|
||||
Name *string
|
||||
VisibilityList []Visibility
|
||||
VisibilityList []storepb.Visibility
|
||||
Tag *string
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,8 @@ package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
storepb "github.com/yourselfhosted/slash/proto/gen/store"
|
||||
)
|
||||
|
||||
// Role is the type of a role.
|
||||
@ -20,7 +22,7 @@ type User struct {
|
||||
// Standard fields
|
||||
CreatedTs int64
|
||||
UpdatedTs int64
|
||||
RowStatus RowStatus
|
||||
RowStatus storepb.RowStatus
|
||||
|
||||
// Domain specific fields
|
||||
Email string
|
||||
@ -32,7 +34,7 @@ type User struct {
|
||||
type UpdateUser struct {
|
||||
ID int32
|
||||
|
||||
RowStatus *RowStatus
|
||||
RowStatus *storepb.RowStatus
|
||||
Email *string
|
||||
Nickname *string
|
||||
PasswordHash *string
|
||||
@ -41,7 +43,7 @@ type UpdateUser struct {
|
||||
|
||||
type FindUser struct {
|
||||
ID *int32
|
||||
RowStatus *RowStatus
|
||||
RowStatus *storepb.RowStatus
|
||||
Email *string
|
||||
Nickname *string
|
||||
Role *Role
|
||||
|
Reference in New Issue
Block a user