Add config option for always sending active delivery receipts

This commit is contained in:
Tulir Asokan 2022-02-25 01:27:24 +02:00
parent 6705a6f7bf
commit f36b4c18f2
6 changed files with 13 additions and 3 deletions

View file

@ -55,6 +55,8 @@ type BridgeConfig struct {
DefaultBridgeReceipts bool `yaml:"default_bridge_receipts"`
DefaultBridgePresence bool `yaml:"default_bridge_presence"`
ForceActiveDeliveryReceipts bool `yaml:"force_active_delivery_receipts"`
DoublePuppetServerMap map[string]string `yaml:"double_puppet_server_map"`
DoublePuppetAllowDiscovery bool `yaml:"double_puppet_allow_discovery"`
LoginSharedSecretMap map[string]string `yaml:"login_shared_secret_map"`

View file

@ -82,6 +82,7 @@ func (helper *UpgradeHelper) doUpgrade() {
helper.Copy(Bool, "bridge", "sync_direct_chat_list")
helper.Copy(Bool, "bridge", "default_bridge_receipts")
helper.Copy(Bool, "bridge", "default_bridge_presence")
helper.Copy(Bool, "bridge", "force_active_delivery_receipts")
helper.Copy(Map, "bridge", "double_puppet_server_map")
helper.Copy(Bool, "bridge", "double_puppet_allow_discovery")
if legacySecret, ok := helper.Get(Str, "bridge", "login_shared_secret"); ok && len(legacySecret) > 0 {

View file

@ -147,6 +147,12 @@ bridge:
# Existing users won't be affected when these are changed.
default_bridge_receipts: true
default_bridge_presence: true
# Should the bridge always send "active" delivery receipts (two gray ticks on WhatsApp)
# even if the user isn't marked as online (e.g. when presence bridging isn't enabled)?
#
# By default, the bridge acts like WhatsApp web, which only sends active delivery
# receipts when it's in the foreground.
force_active_delivery_receipts: false
# Servers to always allow double puppeting from
double_puppet_server_map:
example.com: https://example.com

2
go.mod
View file

@ -10,7 +10,7 @@ require (
github.com/prometheus/client_golang v1.11.1
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/tidwall/gjson v1.14.0
go.mau.fi/whatsmeow v0.0.0-20220218100006-2613ad3a11a2
go.mau.fi/whatsmeow v0.0.0-20220224232138-21e8bf9d5df8
golang.org/x/image v0.0.0-20211028202545-6944b10bf410
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
google.golang.org/protobuf v1.27.1

4
go.sum
View file

@ -120,8 +120,8 @@ github.com/tidwall/sjson v1.2.4 h1:cuiLzLnaMeBhRmEv00Lpk3tkYrcxpmbU81tAY4Dw0tc=
github.com/tidwall/sjson v1.2.4/go.mod h1:098SZ494YoMWPmMO6ct4dcFnqxwj9r/gF0Etp19pSNM=
go.mau.fi/libsignal v0.0.0-20211109153248-a67163214910 h1:9FFhG0OmkuMau5UEaTgiUQ+7cSbtbOQ7hiWKdN8OI3I=
go.mau.fi/libsignal v0.0.0-20211109153248-a67163214910/go.mod h1:AufGrvVh+00Nc07Jm4hTquh7yleZyn20tKJI2wCPAKg=
go.mau.fi/whatsmeow v0.0.0-20220218100006-2613ad3a11a2 h1:KPN+bsDm9EQtHFph1rd4h+0UNK0fJTI4ilWIfytK278=
go.mau.fi/whatsmeow v0.0.0-20220218100006-2613ad3a11a2/go.mod h1:NNI4Ah/B27mfQNChJMD1iSO8+HS+fQ4WqNuQ8Mh2/XI=
go.mau.fi/whatsmeow v0.0.0-20220224232138-21e8bf9d5df8 h1:VG8ft6ahZOAg9QYARrla10g8CdEC5nEZkaiahxIPbvg=
go.mau.fi/whatsmeow v0.0.0-20220224232138-21e8bf9d5df8/go.mod h1:NNI4Ah/B27mfQNChJMD1iSO8+HS+fQ4WqNuQ8Mh2/XI=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=

View file

@ -322,6 +322,7 @@ var ErrAlreadyLoggedIn = errors.New("already logged in")
func (user *User) createClient(sess *store.Device) {
user.Client = whatsmeow.NewClient(sess, &waLogger{user.log.Sub("Client")})
user.Client.AddEventHandler(user.HandleEvent)
user.Client.SetForceActiveDeliveryReceipts(user.bridge.Config.Bridge.ForceActiveDeliveryReceipts)
user.Client.GetMessageForRetry = func(to types.JID, id types.MessageID) *waProto.Message {
user.bridge.Metrics.TrackRetryReceipt(0, false)
return nil