Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions goneonize/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,22 @@ func SetGroupName(id *C.char, JIDByte *C.uchar, JIDSize C.int, name *C.char) *C.
return C.CString("")
}

//export RejectCall
func RejectCall(id *C.char, JIDByte *C.uchar, JIDSize C.int, callID *C.char) *C.char {
jidbyte := getByteByAddr(JIDByte, JIDSize)
var neoJIDProto defproto.JID
err := proto.Unmarshal(jidbyte, &neoJIDProto)
if err != nil {
return C.CString(err.Error())
}
// callFrom is the caller's JID (the CallOffer creator); whatsmeow addresses the <reject> to it.
status_err := clients[C.GoString(id)].RejectCall(context.Background(), utils.DecodeJidProto(&neoJIDProto), C.GoString(callID))
if status_err != nil {
return C.CString(status_err.Error())
}
return C.CString("")
}

//export SetGroupPhoto
func SetGroupPhoto(id *C.char, JIDByte *C.uchar, JIDSize C.int, Photo *C.uchar, PhotoSize C.int) *C.struct_BytesReturn {
var neoJIDProto defproto.JID
Expand Down
8 changes: 8 additions & 0 deletions neonize/_binder.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ def _to_c_struct(self) -> "_CProxySettings":
ctypes.c_char_p,
]
gocode.SetGroupName.restype = ctypes.c_void_p
gocode.RejectCall.argtypes = [
ctypes.c_char_p,
ctypes.c_char_p,
ctypes.c_int,
ctypes.c_char_p,
]
gocode.RejectCall.restype = ctypes.c_void_p
gocode.GetGroupInviteLink.argtypes = [
ctypes.c_char_p,
ctypes.c_char_p,
Expand Down Expand Up @@ -612,6 +619,7 @@ def consume_cstring(result, func, arguments):
"Neonize",
"LeaveGroup",
"SetGroupName",
"RejectCall",
"SendChatPresence",
"GenerateMessageID",
"FollowNewsletter",
Expand Down
24 changes: 24 additions & 0 deletions neonize/aioze/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,30 @@ async def revoke_message(self, chat: JID, sender: JID, message_id: str) -> SendR
"""
return await self.send_message(chat, await self.build_revoke(chat, sender, message_id))

async def reject_call(self, call_from: JID, call_id: str) -> str:
"""Reject (decline) an incoming call.

Wraps whatsmeow's ``Client.RejectCall``: the call is terminated on the same
connection that received the offer. ``call_from`` must be the caller's JID
exactly as delivered in the CallOffer (a phone-number or a hosted ``@lid`` JID).

:param call_from: JID of the caller (the CallOffer creator).
:type call_from: JID
:param call_id: The call id (CallOffer id).
:type call_id: str
:return: An empty string on success, otherwise the error text.
:rtype: str
"""
jidbuf = call_from.SerializeToString()
return (
await self.__client.RejectCall(
self.uuid,
jidbuf,
len(jidbuf),
ctypes.create_string_buffer(call_id.encode()),
)
).decode()

async def build_poll_vote_creation(
self,
name: str,
Expand Down
19 changes: 19 additions & 0 deletions neonize/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,25 @@ def revoke_message(self, chat: JID, sender: JID, message_id: str) -> SendRespons
"""
return self.send_message(chat, self.build_revoke(chat, sender, message_id))

def reject_call(self, call_from: JID, call_id: str) -> str:
"""Reject (decline) an incoming call.

Wraps whatsmeow's ``Client.RejectCall``: the call is terminated on the same
connection that received the offer. ``call_from`` must be the caller's JID
exactly as delivered in the CallOffer (a phone-number or a hosted ``@lid`` JID).

:param call_from: JID of the caller (the CallOffer creator).
:type call_from: JID
:param call_id: The call id (CallOffer id).
:type call_id: str
:return: An empty string on success, otherwise the error text.
:rtype: str
"""
jidbuf = call_from.SerializeToString()
return self.__client.RejectCall(
self.uuid, jidbuf, len(jidbuf), ctypes.create_string_buffer(call_id.encode())
).decode()

def build_poll_vote_creation(
self,
name: str,
Expand Down