Compare commits

...

2 Commits

Author SHA1 Message Date
Peter Steinberger
12ae888e1c fix: only override device platform when set (#4) (thanks @zats) 2026-01-23 04:08:09 +00:00
Sash Zats
4ff90cac97 Add linked device label 2026-01-23 04:07:20 +00:00
2 changed files with 34 additions and 0 deletions

View File

@ -6,6 +6,7 @@
- Start tracking changes for the next release (from 2026-01-23).
- Send: `wacli send file --filename` to override display name for uploads. (#7 — thanks @plattenschieber)
- Auth: allow optional `WACLI_DEVICE_LABEL` and `WACLI_DEVICE_PLATFORM` overrides for linked device identity. (#4 — thanks @zats)
### Fixed

View File

@ -2,10 +2,43 @@ package main
import (
"os"
"strings"
"go.mau.fi/whatsmeow/proto/waCompanionReg"
"go.mau.fi/whatsmeow/store"
"google.golang.org/protobuf/proto"
)
func main() {
applyDeviceLabel()
if err := execute(os.Args[1:]); err != nil {
os.Exit(1)
}
}
func applyDeviceLabel() {
label := strings.TrimSpace(os.Getenv("WACLI_DEVICE_LABEL"))
platformRaw := strings.TrimSpace(os.Getenv("WACLI_DEVICE_PLATFORM"))
if platformRaw != "" {
platform := parsePlatformType(platformRaw)
store.DeviceProps.PlatformType = platform.Enum()
}
if label == "" {
return
}
store.SetOSInfo(label, [3]uint32{0, 1, 0})
store.BaseClientPayload.UserAgent.Device = proto.String(label)
store.BaseClientPayload.UserAgent.Manufacturer = proto.String(label)
}
func parsePlatformType(raw string) waCompanionReg.DeviceProps_PlatformType {
value := strings.TrimSpace(raw)
if value == "" {
return waCompanionReg.DeviceProps_CHROME
}
value = strings.ToUpper(value)
if enumValue, ok := waCompanionReg.DeviceProps_PlatformType_value[value]; ok {
return waCompanionReg.DeviceProps_PlatformType(enumValue)
}
return waCompanionReg.DeviceProps_CHROME
}