Skip to content

Instantly share code, notes, and snippets.

@r10s
Last active October 21, 2020 19:34
Show Gist options
  • Save r10s/50b4c95acb85ca02ec2aebed5a94f04c to your computer and use it in GitHub Desktop.
Save r10s/50b4c95acb85ca02ec2aebed5a94f04c to your computer and use it in GitHub Desktop.
check delta chat group creation
// this snippet does not care about freeing allocated objects!
dc_context_t* context = dc_context_new(NULL, NULL, NULL);
dc_delete_file(context, "/tmp/somefile");
dc_open(context, "/tmp/somefile", NULL);
int contact_id1 = dc_create_contact(context, "some1", "[email protected]");
int contact_id2 = dc_create_contact(context, "some2", "[email protected]");
int chat_id = dc_create_group_chat(context, 0, "title1");
dc_add_contact_to_chat(context, chat_id, contact_id1);
dc_add_contact_to_chat(context, chat_id, contact_id2);
dc_array_t* chat_contacts = dc_get_chat_contacts(context, chat_id);
for (size_t i=0; i<dc_array_get_cnt(chat_contacts); i++ ) {
// prints `10 - 11 - 1 - ` the 1 is SELF that is always added to group chats
printf("%i - ", dc_array_get_id(chat_contacts, i));
}
printf("\n");
dc_array_t* all_contacts = dc_get_contacts(context, 0, NULL);
for (size_t i=0; i<dc_array_get_cnt(all_contacts); i++ ) {
// prints `10 - 11 - ` - DC_GCL_ADD_SELF is not added to flags
printf("%i - ", dc_array_get_id(all_contacts, i));
}
@r10s
Copy link
Author

r10s commented Sep 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment