Version: v0.1.0 Latest Latest

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

Go to latest
Published: Jul 29, 2020 License: AGPL-3.0 Imports: 24 Imported by: 0



* Meilindex - mail indexing and search tool. * Copyright (C) 2020 Tero Vierimaa * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <>. * *



This section is empty.


This section is empty.


func ParseAttachments

func ParseAttachments(contentType string) string

func SearchMail

func SearchMail(query string, filter string)


type Filter

type Filter struct {
	After  time.Time
	Before time.Time
	// contains filtered or unexported fields

Filter is structured filter from user to meilisearch.

func NewFilter

func NewFilter(query string) *Filter

NewFilter parses human-formatted filter into meilisearch filter.

func (*Filter) Query

func (f *Filter) Query() string

type Imap

type Imap struct {
	Url                 string
	Tls                 bool
	TlsSkipVerification bool
	Username            string
	Password            string
	// contains filtered or unexported fields

func (*Imap) Connect

func (i *Imap) Connect() error

func (*Imap) Disconnect

func (i *Imap) Disconnect() error

func (*Imap) FetchMail

func (i *Imap) FetchMail() ([]*Mail, error)

func (*Imap) Mailboxes

func (i *Imap) Mailboxes() []string

func (*Imap) SelectMailbox

func (i *Imap) SelectMailbox(name string) error

type Mail

type Mail struct {
	// Uid is hash calculated from id. Uid contains only ascii characters.
	Uid string `json:"uid"`
	// Original message id
	Id              string    `json:"id"`
	From            string    `json:"from"`
	To              []string  `json:"to"`
	Cc              []string  `json:"cc"`
	Subject         string    `json:"subject"`
	Body            string    `json:"body"`
	Timestamp       time.Time `json:"date"`
	Folder          string    `json:"folder"`
	Attachments     [][]byte
	AttachmentNames []string

func ReadFiles

func ReadFiles(file string, recursive bool, flushFunc func(mails []*Mail) error) ([]*Mail, error)

ReadFiles reads files and flushes batched mails to flushFunc

func (*Mail) Date

func (m *Mail) Date() string

Date returns date part of timestamp

func (*Mail) DateTime

func (m *Mail) DateTime() string

DateTime returns date and local time

func (*Mail) HighlightedBody

func (m *Mail) HighlightedBody() string

func (*Mail) HighlightedFrom

func (m *Mail) HighlightedFrom() string

func (*Mail) HighlightedSubject

func (m *Mail) HighlightedSubject() string

func (*Mail) Sanitize

func (m *Mail) Sanitize()

Sanitize makes various mail attributes nicer to read.

func (*Mail) ShortDateTime

func (m *Mail) ShortDateTime() string

ShortDateTime returns short / simple format for date, today, yesterday at xx.xx, date

func (*Mail) String

func (m *Mail) String() string

type Meilisearch

type Meilisearch struct {
	Url    string
	Index  string
	ApiKey string
	// contains filtered or unexported fields

Meilisearch is a connector to Meilisearch.

func NewMeiliSearch

func NewMeiliSearch() (*Meilisearch, error)

NewMeilisearch creates new connection.

func (*Meilisearch) Connect

func (m *Meilisearch) Connect() error

Connect creates a connection to meilisearch instance and initializes index if neccessary.

func (*Meilisearch) IndexComplete

func (m *Meilisearch) IndexComplete() bool

func (*Meilisearch) IndexMail

func (m *Meilisearch) IndexMail(mails []*Mail) error

func (*Meilisearch) IndexMailBackground

func (m *Meilisearch) IndexMailBackground(mail []*Mail) error

IndexMailBackground runs multiple goroutines (num of cpus) to push mails to meilisearch. If all goroutines are busy, this call blocks as long as some goroutine is available.

func (*Meilisearch) Query

func (m *Meilisearch) Query(query, filter string) ([]*Mail, int, error)

func (*Meilisearch) RankingRules

func (m *Meilisearch) RankingRules() (*[]string, error)

RankingRules returns a list of ranking rules. First rule is the most important, last is least important.

func (*Meilisearch) ServerVersion

func (m *Meilisearch) ServerVersion() (string, error)

func (*Meilisearch) SetRankingRules

func (m *Meilisearch) SetRankingRules(rules []string) error

func (*Meilisearch) SetStopWords

func (m *Meilisearch) SetStopWords(words []string) error

func (*Meilisearch) SetSynonyms

func (m *Meilisearch) SetSynonyms(synonyms *map[string][]string) error

func (*Meilisearch) Stats

func (m *Meilisearch) Stats() ServerStats

func (*Meilisearch) StopWords

func (m *Meilisearch) StopWords() (*[]string, error)

StopWords returns all stop words currently being used.

func (*Meilisearch) Synonyms

func (m *Meilisearch) Synonyms() (*map[string][]string, error)

func (*Meilisearch) WaitIndexComplete

func (m *Meilisearch) WaitIndexComplete()

type ServerStats

type ServerStats struct {
	NumDocuments     int64
	Indexing         bool
	ServerVersion    string
	MinServerVersion string

Jump to

Keyboard shortcuts

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