Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #22 from gqmelo/attachment-upload
Browse files Browse the repository at this point in the history
Add support to send attachment on a conversation
  • Loading branch information
gqmelo authored Jun 13, 2018
2 parents 16522ad + 5bb0989 commit 1309251
Show file tree
Hide file tree
Showing 7 changed files with 447 additions and 9 deletions.
15 changes: 14 additions & 1 deletion chime/chime-connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,8 @@ chime_connection_send_message_async(ChimeConnection *self,
const gchar *message,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
gpointer user_data,
JsonObject *additional_json)
{
g_return_if_fail(CHIME_IS_CONNECTION(self));
ChimeConnectionPrivate *priv = CHIME_CONNECTION_GET_PRIVATE (self);
Expand Down Expand Up @@ -1069,6 +1070,18 @@ chime_connection_send_message_async(ChimeConnection *self,
CHIME_IS_ROOM(obj) ? "room" : "conversation",
chime_object_get_id(obj));
JsonNode *node = json_builder_get_root(jb);
JsonObject *json_obj = json_node_get_object(node);
if (additional_json) {
GList *members_head = json_object_get_members(additional_json);
GList *member = members_head;
while (member != NULL) {
gchar *member_name = (gchar*)member->data;
JsonNode *member_node = json_object_dup_member(additional_json, member_name);
json_object_set_member(json_obj, member_name, member_node);
member = member->next;
}
g_list_free(members_head);
}
chime_connection_queue_http_request(self, node, uri, "POST", send_message_cb, task);

json_node_unref(node);
Expand Down
3 changes: 2 additions & 1 deletion chime/chime-object.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ void chime_connection_send_message_async (ChimeConnection
const gchar *message,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gpointer user_data,
JsonObject *additional_json);

JsonNode *chime_connection_send_message_finish (ChimeConnection *self,
GAsyncResult *result,
Expand Down
Loading

0 comments on commit 1309251

Please sign in to comment.