mailservers

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: MPL-2.0 Imports: 17 Imported by: 0

README

Mailservers Service

Mailservers service provides read/write API for Mailserver object which stores details about user's mailservers.

To enable this service, include mailservers in APIModules:

{
  "MailserversConfig": {
    "Enabled": true
  },
  "APIModules": "mailservers"
}

API

Enabling service will expose three additional methods:

mailservers_addMailserver

Stores Mailserver in the database.

{
    "id": "1",
    "name": "my mailserver",
    "address": "enode://...",
    "password": "some-pass",
    "fleet": "prod"
}
mailservers_getMailservers

Reads all saved mailservers.

mailservers_deleteMailserver

Deletes a mailserver specified by an ID.

Mailserver requests gap service

Mailserver request gaps service provides read/write API for MailserverRequestGap object which stores details about the gaps between mailserver requests.

API

The service exposes four methods

mailserverrequestgaps_addMailserverRequestGaps

Stores MailserverRequestGap in the database. All fields are specified below:

{
  "id": "1",
  "chatId": "chat-id",
  "from": 1,
  "to": 2
}
mailservers_getMailserverRequestGaps

Reads all saved mailserver request gaps by chatID.

mailservers_deleteMailserverRequestGaps

Deletes all MailserverRequestGaps specified by IDs.

mailservers_deleteMailserverRequestGapsByChatID

Deletes all MailserverRequestGaps specified by chatID.

mailservers_addMailserverTopic

Stores MailserverTopic in the database.

{
    "topic": "topic-as-string",
    "chat-ids": ["a", "list", "of", "chatIDs"],
    "last-request": 1
}
mailservers_getMailserverTopics

Reads all saved mailserver topics.

mailservers_deleteMailserverTopic

Deletes a mailserver topic using topic as an identifier.

mailservers_addChatRequestRange

Stores ChatRequestRange in the database.

{
    "chat-id": "chat-id-001",
    "lowest-request-from": 1567693421154,
    "highest-request-to": 1567693576779 
}
mailservers_getChatRequestRanges

Reads all saved chat request ranges.

mailservers_deleteChatRequestRange

Deletes a chat request range by chat-id.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustDecodeENR added in v0.185.0

func MustDecodeENR(enrStr string) *enode.Node

func MustDecodeMultiaddress added in v0.185.0

func MustDecodeMultiaddress(multiaddrsStr string) *multiaddr.Multiaddr

Types

type API

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

API is class with methods available over RPC.

func NewAPI

func NewAPI(db *Database) *API

func (*API) AddChatRequestRange

func (a *API) AddChatRequestRange(ctx context.Context, req ChatRequestRange) error

func (*API) AddChatRequestRanges added in v0.69.0

func (a *API) AddChatRequestRanges(ctx context.Context, reqs []ChatRequestRange) error

func (*API) AddMailserver

func (a *API) AddMailserver(ctx context.Context, m Mailserver) error

func (*API) AddMailserverRequestGaps

func (a *API) AddMailserverRequestGaps(ctx context.Context, gaps []MailserverRequestGap) error

func (*API) AddMailserverTopic

func (a *API) AddMailserverTopic(ctx context.Context, topic MailserverTopic) error

func (*API) AddMailserverTopics added in v0.69.0

func (a *API) AddMailserverTopics(ctx context.Context, topics []MailserverTopic) error

func (*API) DeleteChatRequestRange

func (a *API) DeleteChatRequestRange(ctx context.Context, chatID string) error

func (*API) DeleteMailserver

func (a *API) DeleteMailserver(ctx context.Context, id string) error

func (*API) DeleteMailserverRequestGaps

func (a *API) DeleteMailserverRequestGaps(ctx context.Context, ids []string) error

func (*API) DeleteMailserverRequestGapsByChatID

func (a *API) DeleteMailserverRequestGapsByChatID(ctx context.Context, chatID string) error

func (*API) DeleteMailserverTopic

func (a *API) DeleteMailserverTopic(ctx context.Context, pubsubTopic string, topic string) error

func (*API) GetChatRequestRanges

func (a *API) GetChatRequestRanges(ctx context.Context) ([]ChatRequestRange, error)

func (*API) GetMailserverRequestGaps

func (a *API) GetMailserverRequestGaps(ctx context.Context, chatID string) ([]MailserverRequestGap, error)

func (*API) GetMailserverTopics

func (a *API) GetMailserverTopics(ctx context.Context) ([]MailserverTopic, error)

func (*API) GetMailservers

func (a *API) GetMailservers(ctx context.Context) ([]Mailserver, error)

type ChatRequestRange

type ChatRequestRange struct {
	ChatID            string `json:"chat-id"`
	LowestRequestFrom int    `json:"lowest-request-from"`
	HighestRequestTo  int    `json:"highest-request-to"`
}

type Database

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

Database sql wrapper for operations with mailserver objects.

func NewDB

func NewDB(db *sql.DB) *Database

func (*Database) Add

func (d *Database) Add(mailserver Mailserver) error

func (*Database) AddChatRequestRange

func (d *Database) AddChatRequestRange(req ChatRequestRange) error

func (*Database) AddChatRequestRanges added in v0.69.0

func (d *Database) AddChatRequestRanges(reqs []ChatRequestRange) (err error)

func (*Database) AddGaps

func (d *Database) AddGaps(gaps []MailserverRequestGap) error

func (*Database) AddTopic

func (d *Database) AddTopic(topic MailserverTopic) error

func (*Database) AddTopics added in v0.69.0

func (d *Database) AddTopics(topics []MailserverTopic) (err error)

func (*Database) ChatRequestRanges

func (d *Database) ChatRequestRanges() ([]ChatRequestRange, error)

func (*Database) Delete

func (d *Database) Delete(id string) error

func (*Database) DeleteChatRequestRange

func (d *Database) DeleteChatRequestRange(chatID string) error

func (*Database) DeleteGaps

func (d *Database) DeleteGaps(ids []string) error

func (*Database) DeleteGapsByChatID

func (d *Database) DeleteGapsByChatID(chatID string) error

func (*Database) DeleteTopic

func (d *Database) DeleteTopic(pubsubTopic, contentTopic string) error

func (*Database) Mailservers

func (d *Database) Mailservers() ([]Mailserver, error)

func (*Database) RequestGaps

func (d *Database) RequestGaps(chatID string) ([]MailserverRequestGap, error)

func (*Database) ResetLastRequest added in v0.92.4

func (d *Database) ResetLastRequest(pubsubTopic, contentTopic string) error

func (*Database) SetTopics added in v0.69.0

func (d *Database) SetTopics(filters []*transport.Filter) (err error)

SetTopics deletes all topics excepts the one set, or upsert those if missing

func (*Database) Topics

func (d *Database) Topics() ([]MailserverTopic, error)

type Mailserver

type Mailserver struct {
	ID     string               `json:"id"`
	Name   string               `json:"name"`
	Custom bool                 `json:"custom"`
	ENR    *enode.Node          `json:"enr"`
	Addr   *multiaddr.Multiaddr `json:"addr"`

	// Deprecated: only used with WakuV1
	Password       string `json:"password,omitempty"`
	Fleet          string `json:"fleet"`
	FailedRequests uint   `json:"-"`
}

func DefaultMailservers added in v0.96.0

func DefaultMailservers() []Mailserver

func DefaultMailserversByFleet added in v0.171.40

func DefaultMailserversByFleet(fleet string) []Mailserver

func (Mailserver) PeerID added in v0.96.0

func (m Mailserver) PeerID() (peer.ID, error)

func (Mailserver) PeerInfo added in v0.185.0

func (m Mailserver) PeerInfo() (*peer.AddrInfo, error)

type MailserverRequestGap

type MailserverRequestGap struct {
	ID     string `json:"id"`
	ChatID string `json:"chatId"`
	From   uint64 `json:"from"`
	To     uint64 `json:"to"`
}

type MailserverTopic

type MailserverTopic struct {
	PubsubTopic  string   `json:"pubsubTopic"`
	ContentTopic string   `json:"topic"`
	Discovery    bool     `json:"discovery?"`
	Negotiated   bool     `json:"negotiated?"`
	ChatIDs      []string `json:"chat-ids"`
	LastRequest  int      `json:"last-request"` // default is 1
}

type Service

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

func NewService

func NewService(db *Database) *Service

func (*Service) APIs

func (s *Service) APIs() []rpc.API

func (*Service) Protocols

func (s *Service) Protocols() []p2p.Protocol

func (*Service) Start

func (s *Service) Start() error

func (*Service) Stop

func (s *Service) Stop() error

Jump to

Keyboard shortcuts

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