Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
handling of code removal for repeat reminders commented. quick ignore…
Browse files Browse the repository at this point in the history
… of empty target for triggered reminder
  • Loading branch information
scottleedavis committed Apr 20, 2019
1 parent 465582b commit ec90079
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "com.github.scottleedavis.mattermost-plugin-remind",
"name": "Remind Bot Mattermost Plugin",
"description": "Sets Reminders",
"version": "0.1.4",
"version": "0.1.5",
"server": {
"executables": {
"linux-amd64": "server/dist/plugin-linux-amd64",
Expand Down
2 changes: 1 addition & 1 deletion server/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ var manifest = struct {
Version string
}{
Id: "com.github.scottleedavis.mattermost-plugin-remind",
Version: "0.1.4",
Version: "0.1.5",
}
6 changes: 4 additions & 2 deletions server/occurrence.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ type Occurrence struct {

ReminderId string

Repeat string

Occurrence time.Time

Snoozed time.Time

Repeat string
}

func (p *Plugin) ClearScheduledOccurrence(reminder Reminder, occurrence Occurrence) {
Expand Down Expand Up @@ -222,7 +222,9 @@ func (p *Plugin) addOccurrences(request *ReminderRequest, occurrences []time.Tim
}

request.Reminder.Occurrences = append(request.Reminder.Occurrences, occurrence)

p.upsertOccurrence(&occurrence)

}

return nil
Expand Down
26 changes: 16 additions & 10 deletions server/reminder.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ func (p *Plugin) TriggerReminders() {
T, _ := p.translation(user)
reminder := p.findReminder(reminders, occurrence)

if reminder.Target == "" {
p.API.LogError("No target found for reminder")
continue
}

if strings.HasPrefix(reminder.Target, "@") || strings.HasPrefix(reminder.Target, T("me")) { //@user

var targetId string
Expand Down Expand Up @@ -344,16 +349,17 @@ func (p *Plugin) UpsertReminder(request *ReminderRequest) error {
}

duplicateReminder := false
for _, r := range reminders {
r.Id = request.Reminder.Id
if r.Username == request.Reminder.Username &&
r.Target == request.Reminder.Target &&
r.Message == request.Reminder.Message &&
r.When == request.Reminder.When {
duplicateReminder = true
break
}
}
// a feature requested by PM. seems to create undesired results
//for _, r := range reminders {
// r.Id = request.Reminder.Id
// if r.Username == request.Reminder.Username &&
// r.Target == request.Reminder.Target &&
// r.Message == request.Reminder.Message &&
// r.When == request.Reminder.When {
// duplicateReminder = true
// break
// }
//}
if !duplicateReminder {
reminders = append(reminders, request.Reminder)
}
Expand Down

0 comments on commit ec90079

Please sign in to comment.