conversations

package
v0.0.0-...-bf66d8f Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const MinRankChangeConversationDetails = RankModerator
View Source
const MinRankDeleteConversation = RankAdmin
View Source
const MinRankManageMembers = RankModerator

* Permissions

View Source
const MinRankManageModerators = RankAdmin
View Source
const RankAdmin = 2 // Manages moderators and can delete the conversation
View Source
const RankModerator = 1 // Can remove/add users
View Source
const RankUser = 0

* Ranks

View Source
const TypeGroup = 1
View Source
const TypePrivateMessage = 0

Variables

This section is empty.

Functions

func CheckSize

func CheckSize(message string) bool

func GenerateCertificate

func GenerateCertificate(id string, conversation string, sender string) (string, error)

Generate a message certificate (used to verify message sender when editing/deleting messages)

Types

type CertificateClaims

type CertificateClaims struct {
	Message      string `json:"mid"` // Message ID
	Conversation string `json:"c"`   // Conversation ID
	Sender       string `json:"sd"`  // Sender ID
	jwt.RegisteredClaims
}

func GetCertificateClaims

func GetCertificateClaims(certificate string) (*CertificateClaims, bool)

Get all claims in a message certificate

func (*CertificateClaims) Valid

func (m *CertificateClaims) Valid(id string, conversation string, sender string) bool

Check if a message certificate is valid with some parameters

type Conversation

type Conversation struct {
	ID   string `json:"id" gorm:"primaryKey"`
	Type uint   `json:"type" gorm:"not null"`
	Data string `json:"data" gorm:"not null"` // Encrypted with the conversation key
}

type ConversationSpace

type ConversationSpace struct {
	ID   uint   `json:"id" gorm:"primaryKey"` // Conversation ID
	Node uint   `json:"node"`                 // Space node (where the Space is running)
	Data string `json:"data"`                 // Space data
}

type ConversationToken

type ConversationToken struct {
	ID           string `json:"id" gorm:"primaryKey"`
	Conversation string `json:"conversation" gorm:"not null"` // Conversation ID
	Activated    bool   `json:"activated" gorm:"not null"`    // Whether the token is activated or not
	Token        string `json:"token" gorm:"not null,unique"` // Long token required to subscribe to the conversation
	Data         string `json:"data" gorm:"not null"`         // Encrypted data about the user (account id, username, etc.)
	Rank         uint   `json:"rank" gorm:"not null"`
	LastRead     int64  `json:"-" gorm:"not null"`    // Last time the user read the conversation
	Node         int64  `json:"node" gorm:"not null"` // Node ID
}

type Message

type Message struct {
	ID string `json:"id" gorm:"primaryKey"`

	Conversation string `json:"conversation" gorm:"not null"`
	Certificate  string `json:"certificate" gorm:"not null"`
	Creation     int64  `json:"creation"`               // Unix timestamp (SET BY THE CLIENT, EXTREMELY IMPORTANT FOR SIGNATURES)
	Data         string `json:"data" gorm:"not null"`   // Encrypted data
	Edited       bool   `json:"edited" gorm:"not null"` // Edited flag
	Sender       string `json:"sender" gorm:"not null"` // Sender ID (of conversation token)
}

type SentConversationToken

type SentConversationToken struct {
	ID    string `json:"id"`
	Token string `json:"token"`
}

type SpaceData

type SpaceData struct {
	Clients []string `json:"clients"` // List of clients in the space
	Info    string   `json:"info"`    // Space info (encrypted using Space key)
}

Jump to

Keyboard shortcuts

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