Skip to content

Commit

Permalink
[fix] #106
Browse files Browse the repository at this point in the history
  • Loading branch information
yoneyan committed Jul 23, 2021
1 parent aacb5e1 commit 34c23c7
Showing 1 changed file with 38 additions and 16 deletions.
54 changes: 38 additions & 16 deletions pkg/api/core/support/ticket/v0/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,31 +284,53 @@ func GetAdminWebSocket(c *gin.Context) {
if resultTicket.Err != nil {
log.Println(resultTicket.Err)
}
mailTemplate := core.MailTemplate{ProcessID: "signature"}
err = dbMailTemplate.Get(&mailTemplate)
if err != nil {
log.Println(err)
}

if len(resultTicket.Tickets) != 0 {
resultUser := dbUser.Get(user.GIDAndLevel, &core.User{
GroupID: resultTicket.Tickets[0].GroupID,
Level: 1,
})
if resultUser.Err != nil {
log.Println(resultUser.Err)
}
if groupID != 0 {

mailTemplate := core.MailTemplate{ProcessID: "signature"}
err = dbMailTemplate.Get(&mailTemplate)
if err != nil {
log.Println(err)
}
if len(resultUser.User) != 0 {
for _, userTmp := range resultUser.User {
resultUser := dbUser.Get(user.GIDAndLevel, &core.User{
GroupID: resultTicket.Tickets[0].GroupID,
Level: 1,
})
if resultUser.Err != nil {
log.Println(resultUser.Err)
}

if len(resultUser.User) != 0 {
for _, userTmp := range resultUser.User {
//グループ側にメール送信
v0.SendMail(mail.Mail{
ToMail: userTmp.Email,
Subject: "Supportより新着メッセージ",
Content: " " + userTmp.Name + "様\n\n" + "チャットより新着メッセージがあります\n" +
"Webシステムよりご覧いただけます。" + mailTemplate.Message,
})
}
}
} else {
resultUser := dbUser.Get(user.ID, &core.User{
Model: gorm.Model{ID: *resultTicket.Tickets[0].UserID},
})
if resultUser.Err != nil {
log.Println(resultUser.Err)
}

if len(resultUser.User) != 0 {
//グループ側にメール送信
v0.SendMail(mail.Mail{
ToMail: userTmp.Email,
ToMail: resultUser.User[0].Email,
Subject: "Supportより新着メッセージ",
Content: " " + userTmp.Name + "様\n\n" + "チャットより新着メッセージがあります\n" +
Content: " " + resultUser.User[0].Name + "様\n\n" + "チャットより新着メッセージがあります\n" +
"Webシステムよりご覧いただけます。" + mailTemplate.Message,
})
}
}

}

support.Broadcast <- msg
Expand Down

0 comments on commit 34c23c7

Please sign in to comment.