service

package
v0.0.0-...-ebc85b6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Post

type Post struct {
	ID           string
	Timestamp    int
	Name         string
	Avatar       string
	Body         string
	ParentID     string
	RepostID     string
	RoomID       string
	UpvoterIDs   map[string]bool
	DownvoterIDs map[string]bool
	ReplyCount   int
}

func (*Post) Downvote

func (p *Post) Downvote(accountID string) bool

func (Post) DownvoteCount

func (p Post) DownvoteCount() int

func (Post) IsDownvoted

func (p Post) IsDownvoted(accountID string) bool

func (Post) IsUpvoted

func (p Post) IsUpvoted(accountID string) bool

func (*Post) Upvote

func (p *Post) Upvote(accountID string) bool

func (Post) UpvoteCount

func (p Post) UpvoteCount() int

type Repository

type Repository interface {
	Save(post Post) error
	FindByID(id string) (*Post, error)
	FindByParentID(id string, first int, after string, sort bool) (*[]Post, error)
	FindByRoomID(id string, first int, after string, sort bool) (*[]Post, error)
}

Repository interface

type Service

type Service interface {
	Get(id string) (*Post, error)
	Feed(first int, after string) (*[]Post, error)
	Child(parentID string, first int, after string) (*[]Post, error)
	Rooms(roomID string, first int, after string) (*[]Post, error)
	Create(name string, avatar string, body string, parentID string, repostID string, roomID string) (*Post, error)
	Upvote(accountID string, postID string) (*Post, error)
	Downvote(accountID string, postID string) (*Post, error)
}

func NewService

func NewService(repo Repository) Service

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL