Skip to content

Commit

Permalink
fix: remove last seen on
Browse files Browse the repository at this point in the history
  • Loading branch information
paulobernardoaf committed Apr 27, 2023
1 parent 633bb38 commit 8f05297
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 27 deletions.
4 changes: 0 additions & 4 deletions backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"strings"
"time"

"github.com/gomodule/redigo/redis"
"github.com/nyaruka/gocommon/urns"
Expand Down Expand Up @@ -33,9 +32,6 @@ type Backend interface {
// GetContact returns (or creates) the contact for the passed in channel and URN
GetContact(context context.Context, channel Channel, urn urns.URN, auth string, name string) (Contact, error)

// UpdateContactLastSeenOn updates last seen on (and modified on) on the passed in contact
UpdateContactLastSeenOn(ctx context.Context, contactUUID ContactUUID, lastSeenOn time.Time) error

// AddURNtoContact adds a URN to the passed in contact
AddURNtoContact(context context.Context, channel Channel, contact Contact, urn urns.URN) (urns.URN, error)

Expand Down
6 changes: 0 additions & 6 deletions backends/rapidpro/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ func (b *backend) GetContact(ctx context.Context, c courier.Channel, urn urns.UR
return contactForURN(ctx, b, dbChannel.OrgID_, dbChannel, urn, auth, name)
}

// UpdateContactLastSeenOn updates last seen on (and modified on) on the passed in contact
func (b *backend) UpdateContactLastSeenOn(ctx context.Context, contactUUID courier.ContactUUID, lastSeenOn time.Time) error {
_, err := b.db.ExecContext(ctx, `UPDATE contacts_contact SET last_seen_on = $2, modified_on = NOW() WHERE uuid = $1`, contactUUID.String(), lastSeenOn)
return err
}

// AddURNtoContact adds a URN to the passed in contact
func (b *backend) AddURNtoContact(ctx context.Context, c courier.Channel, contact courier.Contact, urn urns.URN) (urns.URN, error) {
tx, err := b.db.BeginTxx(ctx, nil)
Expand Down
12 changes: 0 additions & 12 deletions sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,6 @@ func (w *Sender) sendMessage(msg Msg) {
log.WithField("elapsed", duration).Info("msg sent")
analytics.Gauge(fmt.Sprintf("courier.msg_send_%s", msg.Channel().ChannelType()), secondDuration)
}

// update last seen on if message is no error and no fail
if status.Status() != MsgErrored && status.Status() != MsgFailed {
ctt, err := w.foreman.server.Backend().GetContact(context.Background(), msg.Channel(), msg.URN(), "", "")
if err != nil {
log.WithError(err).Info("error getting contact")
}
err = w.foreman.server.Backend().UpdateContactLastSeenOn(context.Background(), ctt.UUID(), time.Now())
if err != nil {
log.WithError(err).Info("error updating contact last seen on")
}
}
}

// we allot 10 seconds to write our status to the db
Expand Down
5 changes: 0 additions & 5 deletions test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,6 @@ func (mb *MockBackend) GetContact(ctx context.Context, channel Channel, urn urns
return contact, nil
}

// UpdateContactLastSeenOn updates last seen on (and modified on) on the passed in contact
func (mb *MockBackend) UpdateContactLastSeenOn(ctx context.Context, contactUUID ContactUUID, lastSeenOn time.Time) error {
return nil
}

// AddURNtoContact adds a URN to the passed in contact
func (mb *MockBackend) AddURNtoContact(context context.Context, channel Channel, contact Contact, urn urns.URN) (urns.URN, error) {
mb.contacts[urn] = contact
Expand Down

0 comments on commit 8f05297

Please sign in to comment.