2021-02-09 11:53:33 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2021-02-08 11:57:14 +00:00
|
|
|
package admindb
|
|
|
|
|
|
|
|
import (
|
2021-02-09 11:39:57 +00:00
|
|
|
"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
|
|
|
|
2021-02-09 11:39:57 +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-15 10:02:45 +00:00
|
|
|
// AllowListService changes the lists of people that are allowed to get into the room
|
2021-02-11 15:43:19 +00:00
|
|
|
type AllowListService interface {
|
|
|
|
// Add adds the feed to the list.
|
|
|
|
Add(context.Context, refs.FeedRef) error
|
|
|
|
|
2021-02-15 09:40:43 +00:00
|
|
|
// 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
|
|
|
|
2021-02-15 10:02:45 +00:00
|
|
|
// GetByID returns the list entry for that ID or an error
|
|
|
|
GetByID(context.Context, int64) (ListEntry, error)
|
|
|
|
|
2021-02-11 15:43:19 +00:00
|
|
|
// List returns a list of all the feeds.
|
2021-02-15 09:40:43 +00:00
|
|
|
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
|
|
|
|
2021-02-15 09:40:43 +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{}
|
|
|
|
|
2021-02-22 16:55:12 +00:00
|
|
|
// PinnedNoticesService allows an admin to assign Notices to specific placeholder pages.
|
|
|
|
// TODO: better name then _fixed_
|
|
|
|
// like updates, privacy policy, code of conduct
|
|
|
|
// TODO: enum these
|
|
|
|
type PinnedNoticesService interface {
|
|
|
|
// Set assigns a fixed page name to an page ID and a language to allow for multiple translated versions of the same page.
|
|
|
|
Set(name PinnedNoticeName, id int64, lang string) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type NoticesService interface {
|
|
|
|
// GetByID returns the page for that ID or an error
|
|
|
|
GetByID(context.Context, int64) (Notice, error)
|
|
|
|
|
|
|
|
// Save updates the passed page or creates it if it's ID is zero
|
|
|
|
Save(context.Context, *Notice) error
|
|
|
|
|
|
|
|
// RemoveID removes the page for that ID.
|
|
|
|
RemoveID(context.Context, int64) error
|
|
|
|
}
|
|
|
|
|
2021-02-08 11:57:14 +00:00
|
|
|
// 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
|
2021-02-22 16:55:12 +00:00
|
|
|
|
|
|
|
//go:generate counterfeiter -o mockdb/fixed_pages.go . PinnedNoticesService
|
|
|
|
|
|
|
|
//go:generate counterfeiter -o mockdb/pages.go . NoticesService
|