Skip to content

Commit

Permalink
set event to active if time is changed (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
CubicrootXYZ authored Oct 9, 2024
1 parent 289ccc8 commit edc8a5c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions internal/connectors/matrix/actions/reply/change_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func (action *ChangeTimeAction) HandleEvent(event *matrix.MessageEvent, replyToM
}

replyToMessage.Event.Time = remindTime
replyToMessage.Event.Active = true
_, err = action.db.UpdateEvent(replyToMessage.Event)
if err != nil {
action.logger.Errorf("failed to update event in database: %v", err)
Expand Down
8 changes: 6 additions & 2 deletions internal/connectors/matrix/actions/reply/change_time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ func TestChangeTimeAction_HandleEvent(t *testing.T) {
// Expectations
tests.ExpectNewMessageFromEvent(matrixDB, event, matrixdb.MessageTypeChangeEvent, tests.MsgWithDBEventID(1))

db.EXPECT().UpdateEvent(tests.NewEventMatcher(tests.TestMessage().Event)).
e := tests.TestMessage().Event
e.Active = true
db.EXPECT().UpdateEvent(tests.NewEventMatcher(e)).
Return(nil, nil)

msngr.EXPECT().SendResponse(gomock.Any()).Return(&messenger.MessageResponse{
Expand Down Expand Up @@ -118,7 +120,9 @@ func TestChangeTimeAction_HandleEventWithUpdateError(t *testing.T) {
// Expectations
tests.ExpectNewMessageFromEvent(matrixDB, event, matrixdb.MessageTypeChangeEvent, tests.MsgWithDBEventID(1))

db.EXPECT().UpdateEvent(tests.NewEventMatcher(tests.TestMessage().Event)).
e := tests.TestMessage().Event
e.Active = true
db.EXPECT().UpdateEvent(tests.NewEventMatcher(e)).
Return(nil, errors.New("test"))

// Execute
Expand Down

0 comments on commit edc8a5c

Please sign in to comment.