model

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2021 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMessage

func NewMessage(s service.Service, message Message) error

func SignMessage

func SignMessage(secBase64, pubBase64, displayedName, message, messageId string) string

SignMessage signs messages from base64 and return a base64 signature The signature contains these elements concatenated: The message (UTF-8 to bytes) The author's public key The author's declared name The eventual messageId, empty if this is an original post

func VerifyFromString

func VerifyFromString(pub, sig, displayedName, msg, msgId string) bool

Types

type KeyGen

type KeyGen struct {
	Pub            string
	NewPub         string
	ColorPrimary   string // Preview of the primary color of generated key pair
	ColorSecondary string // Preview of the secondary color of generated key pair
	Sec            string
	NewSec         string
	Sig            string
	DisplayedName  string
	Content        string
	MessageID      string
	Verif          bool
	Valid          bool
}

func GenKeys

func GenKeys() KeyGen

GenKeys generates (cryptographically secured) a new pair of ed25519 keys

type Message

type Message struct {
	// Stored and generated
	ID        string `gorm:"primary_key"`
	CreatedAt time.Time

	// Stored and given by user
	DisplayedName   string // Name Chosen by author, no restriction but < 50 char
	AuthorBase64    string // Encoded in URL-safe Base64
	Content         string
	SignatureBase64 string // Encoded in URL-safe Base64
	MessageID       string // Used if the message is a comment to a publication

	// Only for display on client, computed from known values
	Correct        bool   `json:"-" gorm:"-"`
	ColorPrimary   string `json:"-" gorm:"-"`
	ColorSecondary string `json:"-" gorm:"-"`
	DisplayedDate  string `json:"-" gorm:"-"`
	Pod            string `gorm:"-"` // Not saved in db but tell where it is sent from so remains in JSON
}

func CleanMessagesClientSide

func CleanMessagesClientSide(messages []Message) []Message

CleanMessagesOutFromDB get data from DB and do some checks and verifications

func CleanMessagesOutFromDB

func CleanMessagesOutFromDB(messages []Message, url ...string) []Message

CleanMessagesOutFromDB get data from DB and do some checks and verifications

func CleanSingleMessageClientSide

func CleanSingleMessageClientSide(message Message) Message

func CleanSingleMessageOutFromDB

func CleanSingleMessageOutFromDB(message Message, url ...string) Message

func GetAllFromDB

func GetAllFromDB(s service.Service) []Message

GetAllFromDB get data from db and checks some things

func GetCommentsTo

func GetCommentsTo(s service.Service, messageID string) []Message

func GetMessageFromDB

func GetMessageFromDB(s service.Service, id string) (Message, error)

func GetMessagesFromAuthor

func GetMessagesFromAuthor(s service.Service, pubKeyBase64 string) []Message

func GetMessagesFromDB

func GetMessagesFromDB(s service.Service) []Message

GetMessagesFromDB get data from db and checks some things

func GetMostRecentComment

func GetMostRecentComment(s service.Service, messageID string) Message

func GetMostRecentMessage

func GetMostRecentMessage(s service.Service) Message

func SortByDate

func SortByDate(messages []Message) []Message

func (Message) VerifyConditions

func (message Message) VerifyConditions(s service.Service) (int, error)

VerifyConditions returns HTTP status code and an error

func (Message) VerifyOwnerShip

func (message Message) VerifyOwnerShip() bool

Jump to

Keyboard shortcuts

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