mailservers

package
v0.63.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2020 License: MPL-2.0 Imports: 14 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

This section is empty.

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) 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) 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, 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)

func (*API) Ping

func (a *API) Ping(ctx context.Context, pq PingQuery) ([]*PingResult, 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) AddGaps

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

func (*Database) AddTopic

func (d *Database) AddTopic(topic MailserverTopic) 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(topic string) error

func (*Database) Mailservers

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

func (*Database) RequestGaps

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

func (*Database) Topics

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

type Mailserver

type Mailserver struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Address  string `json:"address"`
	Password string `json:"password,omitempty"`
	Fleet    string `json:"fleet"`
}

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 {
	Topic       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 PingQuery

type PingQuery struct {
	Addresses []string `json:"addresses"`
	TimeoutMs int      `json:"timeoutMs"`
}

type PingResult

type PingResult struct {
	ENode string  `json:"address"`
	RTTMs *int    `json:"rttMs"`
	Err   *string `json:"error"`
}

func (*PingResult) Update

func (pr *PingResult) Update(rttMs int, err error)

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(*p2p.Server) 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