internal

package
v0.0.0-...-374e352 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fingerprint

func Fingerprint(rawPubKey string) (string, error)

Fingerprint will attempt to generate a fingerprint from the provided rawPubKey The fingerprint is simply the URL safe, Base64 encoded sha256 hash of the public key

func GenerateDeterministicUUID

func GenerateDeterministicUUID(key, title, namespace string) (string, error)

GenerateDeterministicUUID creates a deterministic (version 5) uuid from the provided key and title

func ParseExpiration

func ParseExpiration(expirationRequest string) *time.Time

ParseExpiration converts common expiration times used on our frontend into actual time periods our post reaper will leverage to expire posts.

func ValidateSignature

func ValidateSignature(rawPubKey string, base64EncodedSignature string, message string) error

ValidateSignature ensures that the signature provided in base64EncodedSignature is valid, i.e. it was signed by the provided rawPubKey and contains the provided message

Types

type CustomValidator

type CustomValidator struct {
	// contains filtered or unexported fields
}

func (*CustomValidator) Validate

func (cv *CustomValidator) Validate(i interface{}) error

type DB

type DB struct {
	// contains filtered or unexported fields
}

func NewDB

func NewDB() DB

func (DB) DeleteExpiredPosts

func (d DB) DeleteExpiredPosts() (int64, error)

func (DB) DeletePost

func (d DB) DeletePost(postDeleteRequest model.PostDeleteRequest) error

DeletePost drops from the db the model.Post and model.PostContent associated with the postDeleteRequest

func (DB) GetPost

func (d DB) GetPost(postUUID string) (*model.Post, error)

func (DB) GetPostContent

func (d DB) GetPostContent(postUUID string) (*model.PostContent, error)

func (DB) GetUserPosts

func (d DB) GetUserPosts(fingerprint string) ([]model.FullPost, error)

GetUserPosts returns all known posts published by the provided fingerprint

func (DB) PersistPost

func (d DB) PersistPost(postUUID string, request model.PostRequest, html string, expiration *time.Time) error

PersistPost derives a model.Post and model.PostContent from the provided request and persists them to the db

type PostManager

type PostManager struct {
	// contains filtered or unexported fields
}

func NewPostManager

func NewPostManager(db DB, cache gcache.Cache) PostManager

func (PostManager) CreatePost

func (pm PostManager) CreatePost(request model.PostRequest) (string, error)

func (PostManager) FetchPostContent

func (pm PostManager) FetchPostContent(postUUID string) (*model.PostContent, error)

func (PostManager) GetAllUserPosts

func (pm PostManager) GetAllUserPosts(fingerprint string) (string, error)

func (PostManager) HasPosts

func (pm PostManager) HasPosts(fingerprint string) (bool, error)

func (PostManager) IsDuplicate

func (pm PostManager) IsDuplicate(request model.PostRequest) (bool, error)

func (PostManager) RemovePost

func (pm PostManager) RemovePost(request model.PostDeleteRequest) error

RemovePost will use the stored public key and post message to delete a post from the provided request iff the signatures can be verified using the stored key/message.

type Router

type Router struct {
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter(db DB, postCreator PostManager) Router

func (Router) Engine

func (r Router) Engine(logFile *os.File) *echo.Echo

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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