message

package
v0.0.0-...-628cd94 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: 6 Imported by: 9

README

SelfDoc

Auto-generated code documentation to make the repository easier to navigate and contribute to.

Last Updated: 2023-05-15

The message directory is for retrieving and sorting information from Gmail messages, including sender and recipient email addresses, message subject and body, message ID, and label ID. It also includes functions for checking if a message was sent by the current user and returning the time the message was created. Additionally, it contains unit tests for various functions in the message package to ensure they return the expected output.

Files

message.go

This file contains functions for retrieving and sorting information from Gmail messages, including sender and recipient email addresses, message subject and body, message ID, and label ID. It also includes functions for checking if a message was sent by the current user and returning the time the message was created.

message_test.go

This file contains unit tests for various functions in the message package, including SortByDate, Header, Body, SenderEmail, RecipientEmail, and HasLabel. The tests cover various scenarios for each function to ensure they return the expected output.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Body

func Body(m *gmail.Message) string

Body returns the body of the message as a string

It first checks for a text/plain body. If none is found, it checks for a text/html body.

func CreatedAt

func CreatedAt(m *gmail.Message) time.Time

CreatedAt returns the time the message was created in the email provider.

For senders, this is the time the message was sent. For recipients, this is the time the message was received.

func HasLabel

func HasLabel(m *gmail.Message, id string) bool

HasLabel returns true if the message contains the given label id

func Header(m *gmail.Message, header string) string

Header returns the value of the header with the given name

func HostMessageID

func HostMessageID(m *gmail.Message) string

HostMessageID returns the message id of the message as it was received by the email provider.

This a convenience function that calls Header(m, "Message-ID")

func IsSent

func IsSent(m *gmail.Message) bool

IsSent returns true if the message was sent by the current user

There are a number of ways to check if a message was sent by a user. This function checks if the message contains the system "SENT" label, which allows us to only fetch the minimal message information (no headers) from a thread.

func Recipient

func Recipient(m *gmail.Message) string

Recipient returns the sender of the message The sender is the email address of the first "To" header

This doesn't support multiple recipients.

func RecipientEmail

func RecipientEmail(m *gmail.Message) string

RecipientEmail returns the email address of the recipient It uses Recipient to get the recipient string, and then extracts the email address from it.

Example: "John Doe" <john.doe@example.com>" -> "john.doe@example.com"

func Sender

func Sender(m *gmail.Message) string

Sender returns the sender of the message The sender is the email address of the first "From" header

func SenderEmail

func SenderEmail(m *gmail.Message) string

SenderEmail returns the email address of the sender It uses Sender to get the sender string, and then extracts the email address from it.

Example: "John Doe" <john.doe@example.com>" -> "john.doe@example.com"

func SortByDate

func SortByDate(messages []*gmail.Message)

SortByDate sorts messages by date received by gmail (ascending) The messages are sorted in place.

func Subject

func Subject(m *gmail.Message) string

Subject returns the subject of the message

Types

This section is empty.

Jump to

Keyboard shortcuts

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