Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
feat(task): disable notification support
Browse files Browse the repository at this point in the history
  • Loading branch information
indes committed Feb 2, 2019
1 parent f4e498d commit b19eb18
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bot/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ func BroadNews(source *model.Source, subs []model.Subscribe, contents []model.Co
var u telebot.User
for _, content := range contents {
for _, sub := range subs {
var disableNotification bool
if sub.EnableNotification == 1 {
disableNotification = false
} else {
disableNotification = true
}
u.ID = int(sub.UserID)
message := `
*%s*
Expand All @@ -54,7 +60,8 @@ func BroadNews(source *model.Source, subs []model.Subscribe, contents []model.Co
message = fmt.Sprintf(message, source.Title, content.Title, content.RawLink, content.TelegraphUrl)

_, err := B.Send(&u, message, &telebot.SendOptions{
ParseMode: telebot.ModeMarkdown,
ParseMode: telebot.ModeMarkdown,
DisableNotification: disableNotification,
})
if err != nil {
log.Println(err)
Expand Down
2 changes: 2 additions & 0 deletions model/subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ func RegistFeed(userID int64, sourceID uint) error {
if err.Error() == "record not found" {
subscribe.UserID = userID
subscribe.SourceID = sourceID
subscribe.EnableNotification = 1
subscribe.EnableTelegraph = 1
err := db.Create(&subscribe).Error
if err == nil {
return nil
Expand Down

0 comments on commit b19eb18

Please sign in to comment.