Last active
October 6, 2018 13:02
-
-
Save ptrcnull/db80bcc9ec6fdc37b2e7dcf3ca39972d to your computer and use it in GitHub Desktop.
Facebook API send_message_response
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void | |
fb_api_cb_publish_ms_r(FbApi *api, GByteArray *pload) | |
{ | |
FbApiMessage *msg; | |
FbApiPrivate *priv = api->priv; | |
FbJsonValues *values; | |
GError *err = NULL; | |
JsonNode *root; | |
if (!fb_api_json_chk(api, pload->data, pload->len, &root)) { | |
return; | |
} | |
values = fb_json_values_new(root); | |
fb_json_values_add(values, FB_JSON_TYPE_BOOL, TRUE, "$.succeeded"); | |
fb_json_values_update(values, &err); | |
FB_API_ERROR_EMIT(api, err, | |
g_object_unref(values); | |
json_node_free(root); | |
return; | |
); | |
if (fb_json_values_next_bool(values, TRUE)) { | |
/* Pop and free the successful message */ | |
msg = g_queue_pop_head(priv->msgs); | |
fb_api_message_free(msg); | |
if (!g_queue_is_empty(priv->msgs)) { | |
msg = g_queue_peek_head(priv->msgs); | |
fb_api_message_send(api, msg); | |
} | |
} else { | |
fb_api_error(api, FB_API_ERROR_GENERAL, | |
"Failed to send message"); | |
} | |
g_object_unref(values); | |
json_node_free(root); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void FacebookChatService::sendMessageResponseReceived(const QFacebookPublishSendMessageResponse &sendMessageResponse) | |
{ | |
auto it = m_undeliveredMessages.find(sendMessageResponse.msgid); | |
if (it == std::end(m_undeliveredMessages)) | |
return; | |
if (sendMessageResponse.succeeded) | |
it->second.setStatus(MessageStatusDelivered); | |
else | |
it->second.setStatus(MessageStatusWontDeliver); | |
m_undeliveredMessages.erase(it); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment