本文整理汇总了Golang中github.com/zond/diplicity/common.SkinnyContext.Env方法的典型用法代码示例。如果您正苦于以下问题:Golang SkinnyContext.Env方法的具体用法?Golang SkinnyContext.Env怎么用?Golang SkinnyContext.Env使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/zond/diplicity/common.SkinnyContext
的用法示例。
在下文中一共展示了SkinnyContext.Env方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: emailTo
func (self *Message) emailTo(c common.SkinnyContext, game *Game, sender *Member, senderUser *user.User, recip *Member, recipUser *user.User, recipName string) (err error) {
mailTag := &MailTag{
M: self.Id,
R: recip.Id,
}
mailTag.H = mailTag.Hash(c.Secret())
encodedMailTag, err := mailTag.Encode()
if err != nil {
return
}
unsubTag := &common.UnsubscribeTag{
T: common.UnsubscribeMessageEmail,
U: recipUser.Id,
}
unsubTag.H = unsubTag.Hash(c.Secret())
encodedUnsubTag, err := unsubTag.Encode()
if err != nil {
return
}
parts := strings.Split(c.ReceiveAddress(), "@")
if len(parts) != 2 {
if c.Env() == common.Development {
parts = []string{"user", "host.tld"}
} else {
err = fmt.Errorf("Failed parsing %#v as an email address", c.ReceiveAddress())
return
}
}
senderName := sender.ShortName(game, senderUser)
replyTo := fmt.Sprintf("%v+%[email protected]%v", parts[0], encodedMailTag, parts[1])
to := fmt.Sprintf("%v <%v>", recipName, recipUser.Email)
memberIds := []string{}
for memberId, _ := range self.RecipientIds {
memberIds = append(memberIds, memberId)
}
sort.Sort(sort.StringSlice(memberIds))
contextLink, err := recipUser.I("To see this message in context: http://%v/games/%v/messages/%v", recipUser.DiplicityHost, self.GameId, self.ChannelId())
if err != nil {
return
}
unsubLink, err := recipUser.I("To unsubscribe: http://%v/unsubscribe/%v", recipUser.DiplicityHost, encodedUnsubTag)
if err != nil {
return
}
body := fmt.Sprintf(common.EmailTemplate, self.Body, contextLink, unsubLink)
subject, err := game.Describe(c, recipUser)
if err != nil {
return
}
go c.SendMail(senderName, replyTo, subject, body, []string{to})
return
}