messaging

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 11 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmailTemplateBody = map[string]string{
	"en/registration_confirmation": `<html>
  <body>
    <p>
      Please confirm your registration by clicking this
      <a href="{{ .registration_url }}/ack/{{ .registration_id }}">link</a>
      and providing the registration code <b><code>{{ .registration_code }}</code></b>
      within the next 45 minutes. If you haven't done so, please re-register.
    </p>

    <p>The registation metadata follows:</p>
    <ul style="list-style-type: disc">
      <li>Session ID: {{ .session_id }}</li>
      <li>Request ID: {{ .request_id }}</li>
      <li>Username: <code>{{ .username }}</code></li>
      <li>Email: <code>{{ .email }}</code></li>
      <li>IP Address: <code>{{ .src_ip }}</code></li>
      <li>Timestamp: {{ .timestamp }}</li>
    </ul>
  </body>
</html>`,
	"en/registration_ready": `<html>
  <body>
    <p>
      The following user successfully registered with the portal.
      Please use management interface to approve or decline the registration.
    </p>

    <p>The registation metadata follows:</p>
    <ul style="list-style-type: disc">
      <li>Registration ID: {{ .registration_id }}</li>
      <li>Registration URL: <code>{{ .registration_url }}</code></li>
      <li>Session ID: {{ .session_id }}</li>
      <li>Request ID: {{ .request_id }}</li>
      <li>Username: <code>{{ .username }}</code></li>
      <li>Email: <code>{{ .email }}</code></li>
      <li>IP Address: <code>{{ .src_ip }}</code></li>
      <li>Timestamp: {{ .timestamp }}</li>
    </ul>
  </body>
</html>`,
	"en/registration_verdict": `<html>
  <body>
    <p>
    {{- if eq .verdict "approved" -}}
      Your registration has been approved.
      You may now login with the username or email
      address below.
    {{- else -}}
      Your registration has been declined.
    {{- end -}}
    </p>
    <p>The registation metadata follows:</p>
    <ul style="list-style-type: disc">
      <li>Username: <code>{{ .username }}</code></li>
      <li>Email: <code>{{ .email }}</code></li>
      <li>Timestamp: {{ .timestamp }}</li>
    </ul>
  </body>
</html>`,
}

EmailTemplateBody stores email body templates.

View Source
var EmailTemplateSubject = map[string]string{
	"en/registration_confirmation": `Registration Confirmation Required`,
	"en/registration_ready":        `Review User Registration`,
	"en/registration_verdict": `{{- if eq .verdict "approved" -}}
User Registration Approved
{{- else -}}
User Registration Declined
{{- end -}}`,
}

EmailTemplateSubject stores email subject templates.

Functions

This section is empty.

Types

type Config

type Config struct {
	EmailProviders []*EmailProvider `json:"email_providers,omitempty" xml:"email_providers,omitempty" yaml:"email_providers,omitempty"`
	FileProviders  []*FileProvider  `json:"file_providers,omitempty" xml:"file_providers,omitempty" yaml:"file_providers,omitempty"`
}

Config represents a collection of various messaging providers.

func (*Config) Add

func (cfg *Config) Add(c Provider) error

Add adds a messaging provider to Config.

func (*Config) ExtractEmailProvider added in v1.0.13

func (cfg *Config) ExtractEmailProvider(s string) *EmailProvider

ExtractEmailProvider returns EmailProvider by name.

func (*Config) ExtractFileProvider added in v1.0.21

func (cfg *Config) ExtractFileProvider(s string) *FileProvider

ExtractFileProvider returns FileProvider by name.

func (*Config) FindProvider added in v1.0.12

func (cfg *Config) FindProvider(s string) bool

FindProvider search for Provider by name.

func (*Config) FindProviderCredentials added in v1.0.12

func (cfg *Config) FindProviderCredentials(s string) string

FindProviderCredentials search for Provider by name and then identifies the credentials used by the provider.

func (*Config) GetProviderType added in v1.0.23

func (cfg *Config) GetProviderType(s string) string

GetProviderType returns type of a messaging provider.

type EmailProvider

type EmailProvider struct {
	Name            string            `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty"`
	Address         string            `json:"address,omitempty" xml:"address,omitempty" yaml:"address,omitempty"`
	Protocol        string            `json:"protocol,omitempty" xml:"protocol,omitempty" yaml:"protocol,omitempty"`
	Credentials     string            `json:"credentials,omitempty" xml:"credentials,omitempty" yaml:"credentials,omitempty"`
	SenderEmail     string            `json:"sender_email,omitempty" xml:"sender_email,omitempty" yaml:"sender_email,omitempty"`
	SenderName      string            `json:"sender_name,omitempty" xml:"sender_name,omitempty" yaml:"sender_name,omitempty"`
	Templates       map[string]string `json:"templates,omitempty" xml:"templates,omitempty" yaml:"templates,omitempty"`
	Passwordless    bool              `json:"passwordless,omitempty" xml:"passwordless,omitempty" yaml:"passwordless,omitempty"`
	BlindCarbonCopy []string          `json:"blind_carbon_copy,omitempty" xml:"blind_carbon_copy,omitempty" yaml:"blind_carbon_copy,omitempty"`
}

EmailProvider represents email messaging provider.

func (*EmailProvider) Send added in v1.0.13

Send sends an email message.

func (*EmailProvider) Validate

func (e *EmailProvider) Validate() error

Validate validates EmailProvider configuration.

type EmailProviderSendInput added in v1.0.21

type EmailProviderSendInput struct {
	Subject     string               `json:"subject,omitempty" xml:"subject,omitempty" yaml:"subject,omitempty"`
	Body        string               `json:"body,omitempty" xml:"body,omitempty" yaml:"body,omitempty"`
	Recipients  []string             `json:"recipients,omitempty" xml:"recipients,omitempty" yaml:"recipients,omitempty"`
	Credentials *credentials.Generic `json:"credentials,omitempty" xml:"credentials,omitempty" yaml:"credentials,omitempty"`
}

EmailProviderSendInput is input for EmailProvider.Send function.

type FileProvider added in v1.0.21

type FileProvider struct {
	Name      string            `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty"`
	RootDir   string            `json:"root_dir,omitempty" xml:"root_dir,omitempty" yaml:"root_dir,omitempty"`
	Templates map[string]string `json:"templates,omitempty" xml:"templates,omitempty" yaml:"templates,omitempty"`
}

FileProvider represents file messaging provider which writes messages to a local file system,

func (*FileProvider) Send added in v1.0.21

Send writes a message to a file system.

func (*FileProvider) Validate added in v1.0.21

func (e *FileProvider) Validate() error

Validate validates FileProvider configuration.

type FileProviderSendInput added in v1.0.21

type FileProviderSendInput struct {
	Subject    string   `json:"subject,omitempty" xml:"subject,omitempty" yaml:"subject,omitempty"`
	Body       string   `json:"body,omitempty" xml:"body,omitempty" yaml:"body,omitempty"`
	Recipients []string `json:"recipients,omitempty" xml:"recipients,omitempty" yaml:"recipients,omitempty"`
}

FileProviderSendInput is input for FileProvider.Send function.

type Provider

type Provider interface {
	Validate() error
}

Provider is an interface to work with messaging providers.

Jump to

Keyboard shortcuts

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