Skip to content

Commit

Permalink
Add missing call event types (#487)
Browse files Browse the repository at this point in the history
As well as some additional internal methods
  • Loading branch information
gerhardberger authored Nov 17, 2023
1 parent 1ec9aef commit 30233d7
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
18 changes: 18 additions & 0 deletions call.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ func (cli *Client) handleCallEvent(node *waBinary.Node) {
},
Data: &child,
})
case "preaccept":
cli.dispatchEvent(&events.CallPreAccept{
BasicCallMeta: basicMeta,
CallRemoteMeta: types.CallRemoteMeta{
RemotePlatform: ag.String("platform"),
RemoteVersion: ag.String("version"),
},
Data: &child,
})
case "transport":
cli.dispatchEvent(&events.CallTransport{
BasicCallMeta: basicMeta,
CallRemoteMeta: types.CallRemoteMeta{
RemotePlatform: ag.String("platform"),
RemoteVersion: ag.String("version"),
},
Data: &child,
})
case "terminate":
cli.dispatchEvent(&events.CallTerminate{
BasicCallMeta: basicMeta,
Expand Down
18 changes: 18 additions & 0 deletions internals.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ package whatsmeow
import (
"context"

"go.mau.fi/libsignal/keys/prekey"

waBinary "go.mau.fi/whatsmeow/binary"
"go.mau.fi/whatsmeow/types"
)
Expand Down Expand Up @@ -66,3 +68,19 @@ func (int *DangerousInternalClient) RequestAppStateKeys(ctx context.Context, key
func (int *DangerousInternalClient) SendRetryReceipt(node *waBinary.Node, info *types.MessageInfo, forceIncludeIdentity bool) {
int.c.sendRetryReceipt(node, info, forceIncludeIdentity)
}

func (int *DangerousInternalClient) EncryptMessageForDevice(plaintext []byte, to types.JID, bundle *prekey.Bundle, extraAttrs waBinary.Attrs) (*waBinary.Node, bool, error) {
return int.c.encryptMessageForDevice(plaintext, to, bundle, extraAttrs)
}

func (int *DangerousInternalClient) GetOwnID() types.JID {
return int.c.getOwnID()
}

func (int *DangerousInternalClient) DecryptDM(child *waBinary.Node, from types.JID, isPreKey bool) ([]byte, error) {
return int.c.decryptDM(child, from, isPreKey)
}

func (int *DangerousInternalClient) MakeDeviceIdentityNode() waBinary.Node {
return int.c.makeDeviceIdentityNode()
}
14 changes: 14 additions & 0 deletions types/events/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ type CallAccept struct {
Data *waBinary.Node
}

type CallPreAccept struct {
types.BasicCallMeta
types.CallRemoteMeta

Data *waBinary.Node
}

type CallTransport struct {
types.BasicCallMeta
types.CallRemoteMeta

Data *waBinary.Node
}

// CallOfferNotice is emitted when the user receives a notice of a call on WhatsApp.
// This seems to be primarily for group calls (whereas CallOffer is for 1:1 calls).
type CallOfferNotice struct {
Expand Down

0 comments on commit 30233d7

Please sign in to comment.