Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track "active" WhatsApp users and implement blocking when reaching the limit #323

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

Half-Shot
Copy link
Contributor

This PR intends to do two things:

  • Store and track activity metrics for whatsapp users, using a metric of minimum days before they are considered active.
  • Block the bridge from sending/receiving traffic when the cap has been reached for active users.

@Half-Shot Half-Shot force-pushed the hs/puppet-activity-metrics-blocking branch from 9068b7b to b5ec1af Compare July 8, 2021 09:36
Copy link

@jaller94 jaller94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good from what I know (and just learned) about Go.
I don't think we're going to use the minDays = 0 right away, but I want to flag that it wouldn't work as I expected it to work.

main.go Outdated Show resolved Hide resolved
metrics.go Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
Copy link

@jaywink jaywink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems sensible, though you'll also need to add PuppetInactivityDays to the config defaults I would suspect, like the other new items?

@@ -1393,6 +1397,9 @@ func (portal *Portal) HandleTextMessage(source *User, message whatsapp.TextMessa
} else {
portal.finishHandling(source, message.Info.Source, resp.EventID)
}
sender := portal.bridge.GetPuppetByJID(message.Info.SenderJid)
sender.UpdateActivityTs(message.Info.Timestamp)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to be careful not to store historical message times.

@@ -60,6 +60,13 @@ type Config struct {
Avatar string `yaml:"avatar"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Add a notice to the admin room

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants