Skip to content

Commit

Permalink
(Pinned)Notices
Browse files Browse the repository at this point in the history
Notices are pages that admins can fill with their content to describe
and customize the room.

Pinned notices are common notices that each room has. Like a description
and privacy policy.

* update models
* simple crud test for basic notices
* edit and save notices as admin
  • Loading branch information
cryptix committed Feb 25, 2021
1 parent 3c921ce commit e5a07fd
Show file tree
Hide file tree
Showing 25 changed files with 2,843 additions and 23 deletions.
24 changes: 24 additions & 0 deletions admindb/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@ type AllowListService interface {
// AliasService manages alias handle registration and lookup
type AliasService interface{}

// 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
}

// for tests we use generated mocks from these interfaces created with https://github.com/maxbrunsfeld/counterfeiter

//go:generate counterfeiter -o mockdb/auth.go . AuthWithSSBService
Expand All @@ -56,3 +76,7 @@ type AliasService interface{}
//go:generate counterfeiter -o mockdb/allow.go . AllowListService

//go:generate counterfeiter -o mockdb/alias.go . AliasService

//go:generate counterfeiter -o mockdb/fixed_pages.go . PinnedNoticesService

//go:generate counterfeiter -o mockdb/pages.go . NoticesService
115 changes: 115 additions & 0 deletions admindb/mockdb/fixed_pages.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e5a07fd

Please sign in to comment.