communication

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2018 License: BSD-3-Clause Imports: 10 Imported by: 4

Documentation

Overview

Package communication contains the implementation for communication channels that itsyou.online can use to communicate with users.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMaxSMS indicates that the sms sending to this number is being rate limited
	ErrMaxSMS = errors.New("Reached the max amount of sms for this phone number, try again later")
)

Functions

func IsRussianMobileNumber added in v0.9.15

func IsRussianMobileNumber(phonenumber string) bool

IsRussianMobileNumber checks if a phone number is a russian mobile. phone numbers need to be passed in E.164 format (leading '+”).

Types

type DevEmailService

type DevEmailService struct{}

DevEmailService is the implementation of an EmailService suitable for use in local development environments

func (*DevEmailService) Send

func (s *DevEmailService) Send(recipients []string, subject string, message string) (err error)

Send sends an Email

type DevSMSService

type DevSMSService struct {
}

DevSMSService is a fake sms service that just logs the sms that should be send

func (*DevSMSService) Send

func (s *DevSMSService) Send(phonenumber string, message string) (err error)

Send sends an SMS

type EmailService

type EmailService interface {
	Send(recipients []string, subject string, message string) (err error)
}

EmailService defines an email communication channel

type RateLimitedSMSService added in v1.0.0

type RateLimitedSMSService struct {
	// contains filtered or unexported fields
}

RateLimitedSMSService wraps an SMS service and applies rate limiting based on the phone number

func (*RateLimitedSMSService) Send added in v1.0.0

func (s *RateLimitedSMSService) Send(phonenumber string, message string) (err error)

Send checksif the message can be send according to the rate limiting rules, and then deligates the acutal sender to the wrapped service. This uses a sliding window approach

type SMSService

type SMSService interface {
	Send(phonenumber string, message string) (err error)
}

SMSService defines an sms communication channel

func NewRateLimitedSMSService added in v1.0.0

func NewRateLimitedSMSService(window int, maxSMS int, actualService SMSService) SMSService

NewRateLimitedSMSService rates limit an existing sms service to the defined rate

type SMSServiceProxySeparateRussia added in v0.9.15

type SMSServiceProxySeparateRussia struct {
	RussianSMSService SMSService
	DefaultSMSService SMSService
}

SMSServiceProxySeparateRussia is an SMS communication channel that uses a separate provider for russian phone numbers

func (*SMSServiceProxySeparateRussia) Send added in v0.9.15

func (s *SMSServiceProxySeparateRussia) Send(phonenumber string, message string) (err error)

Send proxies the send call to the right provider based on the phonenumber

type SMTPEmailService

type SMTPEmailService struct {
	// contains filtered or unexported fields
}

SMTPEmailService implements an email service using plain old SMTP

func NewSMTPEmailService

func NewSMTPEmailService(host string, port int, user string, password string) (service *SMTPEmailService)

NewSMTPEmailService creates a nes SMTPEmailService

func (*SMTPEmailService) Send

func (s *SMTPEmailService) Send(recipients []string, subject string, message string) (err error)

Send sends an Email

type SmsAeroSMSService added in v0.9.15

type SmsAeroSMSService struct {
	Username string
	Password string
	SenderId string
}

SmsAeroSMSService is an SMS communication channel using smsaero

func (*SmsAeroSMSService) Send added in v0.9.15

func (s *SmsAeroSMSService) Send(phonenumber string, message string) (err error)

type TwilioSMSService

type TwilioSMSService struct {
	AccountSID          string
	AuthToken           string
	MessagingServiceSID string
}

TwilioSMSService is an SMS communication channel using Twilio

func (*TwilioSMSService) Send

func (s *TwilioSMSService) Send(phonenumber string, message string) (err error)

Send sends an SMS

Jump to

Keyboard shortcuts

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