email

package
v0.17.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfirmData

type ConfirmData struct {
	// Username to be addressed.
	Username string
	// URL of the instance to
	// present to the receiver.
	InstanceURL string
	// Name of the instance to
	// present to the receiver.
	InstanceName string
	// Link to present to the receiver to
	// click on and do the confirmation.
	// Should be a full link with protocol
	// eg., https://example.org/confirm_email?token=some-long-token
	ConfirmLink string
	// Is this confirm email being sent
	// because this is a new sign-up?
	NewSignup bool
}

ConfirmData represents data passed into the confirm email address template.

type NewReportData added in v0.8.0

type NewReportData struct {
	// URL of the instance to present to the receiver.
	InstanceURL string
	// Name of the instance to present to the receiver.
	InstanceName string
	// URL to open the report in the settings panel.
	ReportURL string
	// Domain from which the report originated.
	// Can be empty string for local reports.
	ReportDomain string
	// Domain targeted by the report.
	// Can be empty string for local reports targeting local users.
	ReportTargetDomain string
}

type NewSignupData added in v0.16.0

type NewSignupData struct {
	// URL of the instance to present to the receiver.
	InstanceURL string
	// Name of the instance to present to the receiver.
	InstanceName string
	// Email address sign-up was created with.
	SignupEmail string
	// Username submitted on the sign-up form.
	SignupUsername string
	// Reason given on the sign-up form.
	SignupReason string
	// URL to open the sign-up in the settings panel.
	SignupURL string
}

type ReportClosedData added in v0.8.0

type ReportClosedData struct {
	// Username to be addressed.
	Username string
	// URL of the instance to present to the receiver.
	InstanceURL string
	// Name of the instance to present to the receiver.
	InstanceName string
	// Username of the report target.
	ReportTargetUsername string
	// Domain of the report target.
	// Can be empty string for local reports targeting local users.
	ReportTargetDomain string
	// Comment left by the admin who closed the report.
	ActionTakenComment string
}

type ResetData

type ResetData struct {
	// Username to be addressed.
	Username string
	// URL of the instance to present to the receiver.
	InstanceURL string
	// Name of the instance to present to the receiver.
	InstanceName string
	// Link to present to the receiver to click on and begin the reset process.
	// Should be a full link with protocol eg., https://example.org/reset_password?token=some-reset-password-token
	ResetLink string
}

ResetData represents data passed into the reset email address template.

type Sender

type Sender interface {
	// SendConfirmEmail sends a 'please confirm your email' style email to the given toAddress, with the given data.
	SendConfirmEmail(toAddress string, data ConfirmData) error

	// SendResetEmail sends a 'reset your password' style email to the given toAddress, with the given data.
	SendResetEmail(toAddress string, data ResetData) error

	// SendTestEmail sends a 'testing email sending' style email to the given toAddress, with the given data.
	SendTestEmail(toAddress string, data TestData) error

	// SendNewReportEmail sends an email notification to the given addresses, letting them
	// know that a new report has been created targeting a user on this instance.
	//
	// It is expected that the toAddresses have already been filtered to ensure that they
	// all belong to admins + moderators.
	SendNewReportEmail(toAddresses []string, data NewReportData) error

	// SendReportClosedEmail sends an email notification to the given address, letting them
	// know that a report that they created has been closed / resolved by an admin.
	SendReportClosedEmail(toAddress string, data ReportClosedData) error

	// SendNewSignupEmail sends an email notification to the given addresses,
	// letting them know that a new sign-up has been submitted to the instance.
	//
	// It is expected that the toAddresses have already been filtered to ensure
	// that they all belong to active admins + moderators.
	SendNewSignupEmail(toAddress []string, data NewSignupData) error

	// SendSignupApprovedEmail sends an email to the given address
	// that their sign-up request has been approved by a moderator.
	SendSignupApprovedEmail(toAddress string, data SignupApprovedData) error

	// SendSignupRejectedEmail sends an email to the given address
	// that their sign-up request has been rejected by a moderator.
	SendSignupRejectedEmail(toAddress string, data SignupRejectedData) error
}

Sender contains functions for sending emails to instance users/new signups.

func NewNoopSender

func NewNoopSender(sendCallback func(toAddress string, message string)) (Sender, error)

NewNoopSender returns a no-op email sender that will just execute the given sendCallback every time it would otherwise send an email to the given toAddress with the given message value.

Passing a nil function is also acceptable, in which case the send functions will just return nil.

func NewSender

func NewSender() (Sender, error)

NewSender returns a new email Sender interface with the given configuration, or an error if something goes wrong.

type SignupApprovedData added in v0.16.0

type SignupApprovedData struct {
	// Username to be addressed.
	Username string
	// URL of the instance to present to the receiver.
	InstanceURL string
	// Name of the instance to present to the receiver.
	InstanceName string
}

type SignupRejectedData added in v0.16.0

type SignupRejectedData struct {
	// Message to the rejected applicant.
	Message string
	// URL of the instance to present to the receiver.
	InstanceURL string
	// Name of the instance to present to the receiver.
	InstanceName string
}

type TestData added in v0.8.0

type TestData struct {
	// Username of admin user who sent the test.
	SendingUsername string
	// (Optional) message to include in the email.
	Message string
	// URL of the instance to present to the receiver.
	InstanceURL string
	// Name of the instance to present to the receiver.
	InstanceName string
}

Jump to

Keyboard shortcuts

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