emailjuice

package
v1.38.7 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Description: This package provides a set of functions to send emails using Fabriktor's email templates. It follows the Google Cloud Pub/Sub message format to send emails asynchronously.

Index

Constants

View Source
const (
	NA = iota
	MaxInfringementsReachedReason
	IdentityUsurpationReason
	ProfileDetectedFakeReason
	ProfileDetectedNotHumanReason
)

To allow to easily pass and retrieve suspension reason from query parameters.

View Source
const (
	TicketsClosureMessage = `` /* 361-byte string literal not displayed */

)

Support related constants.

Variables

This section is empty.

Functions

func EncodeSpecifics added in v1.15.5

func EncodeSpecifics(specifics Specifics) (string, error)

EncodeSpecifics encodes a map of specifics to a JSON string.

func NewPubSubEmail added in v1.15.2

func NewPubSubEmail(templateType TemplateName, targetLanguage, recipientEmail, recipientUsername Key, specifics Specifics) (*pubsub.Message, error)

NewPubSubEmail mimicks the reception of a PubSub email message for testing and previewing purposes.

Do not use this function in production code.

Types

type Key added in v1.15.2

type Key string
const (
	PubSubTemplateTypeKey      Key = "templateType"
	PubSubRecipientUsernameKey Key = "recipientUsername"
	PubSubRecipientEmailKey    Key = "recipientEmail"
	PubSubTargetLanguageKey    Key = "targetLanguage"
	PubSubSpecificsKey         Key = "specifics"
)

Keys represent the key of the attributes of a Google Pub/Sub message to send an email.

type Specifics added in v1.15.6

type Specifics map[SpecificsKey]string

func (Specifics) MarshalJSON added in v1.15.6

func (s Specifics) MarshalJSON() ([]byte, error)

Implementation of json.Marshaler interface for Specifics type.

type SpecificsKey added in v1.15.1

type SpecificsKey string
const (
	// For support template.
	PubSubSpecificsMessageKey SpecificsKey = "msg"
	PubSubSpecificsURLKey     SpecificsKey = "url"

	// For suspension template.
	PubSubSpecificsCountKey SpecificsKey = "count"

	// For suspension template.
	PubSubSpecificsReasonKey SpecificsKey = "reason"

	// For suspicious connection template.
	PubSubSpecificsRequestIPKey    SpecificsKey = "request_ip"
	PubSubSpecificsUserAgentKey    SpecificsKey = "user_agent"
	PubSubSpecificsLocationKey     SpecificsKey = "location"
	PubSubSpecificsConnectionIDKey SpecificsKey = "connection_id"
)

Pub/Sub related constants to be used in the `specifics` attribute of a Google Pub/Sub message.

type SuspensionReason

type SuspensionReason string
const (
	// MaxInfringementsReached represents the reason for suspension when the maximum number of infringements is reached.
	MaxInfringementsReached SuspensionReason = "Maximum number of infringements reached"

	// IdentityUsurpation represents the reason for suspension due to identity usurpation.
	IdentityUsurpation SuspensionReason = "Identity usurpation"

	// ProfileDetectedFake represents the reason for suspension when a profile is detected to be fake.
	ProfileDetectedFake SuspensionReason = "Profile detected to be fake"

	// ProfileDetectedNotHuman represents the reason for suspension when a profile is detected to be non-human, potentially AI, spam, bot, etc.
	ProfileDetectedNotHuman SuspensionReason = "Profile detected to be not human, maybe AI, spam, bot, etc."
)

SuspensionReason represent predefined values for the `reason` subfield of `specifics` attribute of a Google Pub/Sub message.

func GetSuspensionSentence added in v1.17.7

func GetSuspensionSentence(enumValue int) SuspensionReason

GetSuspensionSentence returns the suspension reason as a string.

type TemplateName

type TemplateName string
const (
	WelcomeTemplate    TemplateName = "welcome"    // To greet new users.
	SupportTemplate    TemplateName = "support"    // To respond to tickets.
	DeletionTemplate   TemplateName = "deletion"   // To notify users of account deletion.
	ForbiddenTemplate  TemplateName = "forbidden"  // To notify that forbidden content has been deleted.
	WarningTemplate    TemplateName = "warning"    // To warn a user about to be suspended.
	SuspensionTemplate TemplateName = "suspension" // To notify a user that their account has been suspended.
	ConnectionTemplate TemplateName = "connection" // To notify a user that a suspicious connection has been detected.
)

TemplateName represent the name of Fabriktor's email templates. To be assigned to the `templateType` attribute of a Google Pub/Sub message.

Jump to

Keyboard shortcuts

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