Compare commits
2 Commits
main
...
device-lab
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12ae888e1c | ||
|
|
4ff90cac97 |
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user