go-ssb-room/admindb/interface.go

56 lines
1.7 KiB
Go
Raw Normal View History

2021-02-09 11:53:33 +00:00
// SPDX-License-Identifier: MIT
2021-02-08 11:57:14 +00:00
package admindb
import (
"context"
2021-02-08 11:57:14 +00:00
"go.mindeco.de/http/auth"
2021-02-11 15:43:19 +00:00
refs "go.mindeco.de/ssb-refs"
2021-02-08 11:57:14 +00:00
)
2021-02-08 16:47:42 +00:00
// AuthFallbackService might be helpful for scenarios where one lost access to his ssb device or key
type AuthFallbackService interface {
2021-02-08 11:57:14 +00:00
auth.Auther
2021-02-08 16:47:42 +00:00
Create(ctx context.Context, user string, password []byte) error
GetByID(ctx context.Context, uid int64) (*User, error)
2021-02-08 11:57:14 +00:00
}
2021-02-08 16:47:42 +00:00
// AuthWithSSBService defines functions needed for the challange/response system of sign-in with ssb
type AuthWithSSBService interface{}
2021-02-08 11:57:14 +00:00
2021-02-11 15:43:19 +00:00
// AllowListService deals with changing the privacy modes and managing the allow/deny lists of the room
type AllowListService interface {
// Add adds the feed to the list.
Add(context.Context, refs.FeedRef) error
// HasFeed returns true if a feed is on the list.
HasFeed(context.Context, refs.FeedRef) bool
// HasFeed returns true if a feed is on the list.
HasID(context.Context, int64) bool
2021-02-11 15:43:19 +00:00
// List returns a list of all the feeds.
List(context.Context) (ListEntries, error)
// RemoveFeed removes the feed from the list.
RemoveFeed(context.Context, refs.FeedRef) error
2021-02-11 15:43:19 +00:00
// RemoveID removes the feed for the ID from the list.
RemoveID(context.Context, int64) error
2021-02-11 15:43:19 +00:00
}
2021-02-08 11:57:14 +00:00
// AliasService manages alias handle registration and lookup
type AliasService interface{}
// for tests we use generated mocks from these interfaces created with https://github.com/maxbrunsfeld/counterfeiter
2021-02-08 16:47:42 +00:00
//go:generate counterfeiter -o mockdb/auth.go . AuthWithSSBService
2021-02-08 11:57:14 +00:00
2021-02-08 16:47:42 +00:00
//go:generate counterfeiter -o mockdb/auth_fallback.go . AuthFallbackService
2021-02-08 11:57:14 +00:00
2021-02-11 15:43:19 +00:00
//go:generate counterfeiter -o mockdb/allow.go . AllowListService
2021-02-08 11:57:14 +00:00
//go:generate counterfeiter -o mockdb/alias.go . AliasService