Skip to content

Commit eda65b9

Browse files
arugazcrazycodezombie
authored andcommitted
call: add reject call method (tulir#560)
1 parent f9ac25a commit eda65b9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

call.go

+18
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,21 @@ func (cli *Client) handleCallEvent(node *waBinary.Node) {
9292
cli.dispatchEvent(&events.UnknownCallEvent{Node: node})
9393
}
9494
}
95+
96+
// RejectCall reject an incoming call.
97+
func (cli *Client) RejectCall(callFrom types.JID, callID string) error {
98+
ownID := cli.getOwnID()
99+
if ownID.IsEmpty() {
100+
return ErrNotLoggedIn
101+
}
102+
ownID, callFrom = ownID.ToNonAD(), callFrom.ToNonAD()
103+
return cli.sendNode(waBinary.Node{
104+
Tag: "call",
105+
Attrs: waBinary.Attrs{"id": cli.GenerateMessageID(), "from": ownID, "to": callFrom},
106+
Content: []waBinary.Node{{
107+
Tag: "reject",
108+
Attrs: waBinary.Attrs{"call-id": callID, "call-creator": callFrom, "count": "0"},
109+
Content: nil,
110+
}},
111+
})
112+
}

0 commit comments

Comments
 (0)