Skip to content

Commit 09aa0d3

Browse files
committed
fix: sort channel recurring reminders among recurrent reminders
Before, channel recurring reminders where categorized as channel reminders, which gave them a "Complete" action. But it doesn't make sense to complete a recurring reminder – and it even causes the reminder not to be scheduled again, and eventually to stop working. This commit, by categorizing channel recurring reminders as recurring reminders, make sure they won't be marked as "Completed" by mistake. Probably closes scottleedavis#167
1 parent 88c446a commit 09aa0d3

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

server/list.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ func (p *Plugin) categorizeOccurrences(reminders []Reminder) (
154154
((occurrence.Repeat == "" && isFuture) ||
155155
(s != p.emptyTime && s.After(time.Now().UTC()))) {
156156
upcomingOccurrences = append(upcomingOccurrences, occurrence)
157-
} else if !isChannelReminder &&
158-
occurrence.Repeat != "" && isFuture {
157+
} else if occurrence.Repeat != "" && isFuture {
159158
recurringOccurrences = append(recurringOccurrences, occurrence)
160159
} else if !isCompleted &&
161160
isPast &&

server/list_test.go

+27
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,23 @@ func TestListReminders(t *testing.T) {
9999
Completed: p.emptyTime,
100100
}
101101

102+
channelRecurringReminder := Reminder{
103+
Id: model.NewId(),
104+
Username: user.Username,
105+
Target: "~" + publicChannel.Name,
106+
Message: "This reminder triggers in a channel several times",
107+
When: "every Tuesday at 10:00AM",
108+
Occurrences: []Occurrence{
109+
{
110+
Id: model.NewId(),
111+
ReminderId: model.NewId(),
112+
Repeat: "every Tuesday at 10:00AM",
113+
Occurrence: futureOccurrenceDate,
114+
},
115+
},
116+
Completed: p.emptyTime,
117+
}
118+
102119
setupAPI := func(reminders []Reminder) *plugintest.API {
103120
serializedReminders, _ := json.Marshal(reminders)
104121
api := &plugintest.API{}
@@ -126,6 +143,16 @@ func TestListReminders(t *testing.T) {
126143
assert.Contains(t, attachments[3].Text, T("list.channel"), "The next displayed reminders must be channel reminders")
127144
assert.Contains(t, attachments[len(attachments)-1].Text, T("reminders.page.numbers"), "The last attachment must be list pagination and controls")
128145
})
146+
147+
t.Run("the list categorizes channel-and-recurring reminders with recurring reminders", func(t *testing.T) {
148+
reminders := []Reminder { channelRecurringReminder }
149+
p.API = setupAPI(reminders)
150+
151+
post := p.ListReminders(user, originChannel.Id)
152+
153+
attachments := post.Attachments()
154+
assert.Contains(t, attachments[0].Text, T("list.recurring"), "Reminders both channel and recurring must be categorized with recurring reminders")
155+
})
129156
}
130157

131158
func TestUpdateListReminders(t *testing.T) {

0 commit comments

Comments
 (0)