Skip to content

feat: add GetBusinessProfile - #214

Open
pradosystems wants to merge 1 commit into
krypton-byte:masterfrom
pradosystems:feat/get-business-profile
Open

feat: add GetBusinessProfile#214
pradosystems wants to merge 1 commit into
krypton-byte:masterfrom
pradosystems:feat/get-business-profile

Conversation

@pradosystems

Copy link
Copy Markdown

What

Exposes whatsmeow's GetBusinessProfile, returning the public information a
WhatsApp Business account chose to publish:

profile = client.get_business_profile(build_jid("5511999999999"))
profile.Email
profile.Address
profile.Categories          # [{ID, Name}]
profile.BusinessHoursTimeZone
profile.BusinessHours       # [{DayOfWeek, Mode, OpenTime, CloseTime}]

Why

There is currently no way to reach this from neonize. resolve_business_message_link
only works from a wa.me/message/... link and returns a different, smaller
shape (BusinessMessageLinkTarget), so it does not cover the case of "I have a
JID, what does this business publish?".

It is not reachable via ctypes either — the shipped .so only exports
PutBusinessName and ResolveBusinessMessageLink:

$ nm -D neonize-linux-amd64.so | grep -i business
T PutBusinessName
T ResolveBusinessMessageLink

How

Follows the existing GetProfilePicture pattern end to end:

file change
goneonize/Neonize.proto BusinessProfile, Category, BusinessHoursConfig, GetBusinessProfileReturnFunction
goneonize/utils/encoder.go EncodeBusinessProfile / EncodeCategory / EncodeBusinessHoursConfig
goneonize/main.go //export GetBusinessProfile
neonize/_binder.py ctypes signature
neonize/client.py get_business_profile()
neonize/exc.py GetBusinessProfileError

Two notes on keeping the diff reviewable:

  • New messages were appended at the END of Neonize.proto on purpose. Adding
    them in the middle shifts every following message's descriptor index, which
    alone produced a ~1150-line diff in the regenerated .pb.go. Appending keeps
    it at ~350 lines, almost all of it the new types.
  • Generated files were regenerated with the same toolchain the repo already
    uses — protoc 34.1 and protoc-gen-go v1.36.12 — matching the headers of
    the committed files, so no unrelated churn.

Verification

$ CGO_ENABLED=1 go build -buildmode=c-shared -ldflags=-s -o neonize.so
$ nm -D neonize.so | grep -i "T GetBusinessProfile"
000000000081d4a0 T GetBusinessProfile

I have not added the async variant in aioze/client.py — happy to add it if you
prefer the two kept in sync in the same PR.

Exposes whatsmeow's GetBusinessProfile, which returns the public business
information a WhatsApp Business account chose to publish: address, email,
categories, business hours and timezone.

Currently there is no way to reach this from neonize — the compiled .so only
exports PutBusinessName and ResolveBusinessMessageLink, so it is not
reachable via ctypes either.

Changes follow the existing GetProfilePicture pattern:
- Neonize.proto: BusinessProfile, Category, BusinessHoursConfig and
  GetBusinessProfileReturnFunction. Added at the END of the file on purpose,
  so the descriptor indexes of existing messages do not shift and the
  regenerated .pb.go diff stays small.
- utils/encoder.go: EncodeBusinessProfile / EncodeCategory /
  EncodeBusinessHoursConfig
- main.go: //export GetBusinessProfile
- _binder.py, client.py, exc.py: ctypes signature, wrapper and error type

Generated files were regenerated with the same toolchain the repo already
uses (protoc 34.1 / protoc-gen-go v1.36.12).

Verified: builds with CGO_ENABLED=1 go build -buildmode=c-shared, and
'nm -D' confirms the GetBusinessProfile symbol is exported.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant