-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create room #30
Create room #30
Conversation
This works, however: When joining an existing room by alias, only the internal room name is listed at the top of the pidgin UI. A followup patch may be needed to grab the actual room name and display in pidgin. Signed-off-by: Damien Zammit <damien@zamaudio.com>
There is no hook in purple that allows to create a room separately from joining a room. In matrix there is a distinction. Therefore, try to join by either alias/id and if this fails, create the room. Currently this results in a disconnect but upon reconnecting you become a member of the new room. Signed-off-by: Damien Zammit <damien@zamaudio.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, this is much clearer but there are a few points to address. Thanks!
@@ -54,6 +55,33 @@ static const char *matrixprpl_list_icon(PurpleAccount *acct, PurpleBuddy *buddy) | |||
} | |||
|
|||
/** | |||
* Callback for when joining a room fails, create the room | |||
*/ | |||
static void room_create_callback(MatrixConnectionData *conn, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please could you find a better name for this - get_roomid_by_alias_failed_callback
or something.
} | ||
errorstr = json_object_get_string_member(root_obj, "error"); | ||
errcodestr = json_object_get_string_member(root_obj, "errcode"); | ||
char roomid[strlen(errorstr) - 20]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is unportable. Please use malloc/free.
errcodestr = json_object_get_string_member(root_obj, "errcode"); | ||
char roomid[strlen(errorstr) - 20]; | ||
if (errcodestr && !strcmp(errcodestr, "M_NOT_FOUND")) { | ||
snprintf(roomid, strlen(errorstr) - 20, "%s", &errorstr[11]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this trying to fish the room alias out of the error string? what happens if the error string changes?
You should be able to get the alias from the user_data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, alias != id. Please don't call it roomid
if it's not a room id.
@@ -171,6 +171,13 @@ MatrixApiRequestData *matrix_api_sync(MatrixConnectionData *conn, | |||
gpointer user_data); | |||
|
|||
|
|||
MatrixApiRequestData *matrix_api_create_room(MatrixConnectionData *conn, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still needs docs
@@ -243,6 +250,13 @@ MatrixApiRequestData *matrix_api_join_room(MatrixConnectionData *conn, | |||
gpointer user_data); | |||
|
|||
|
|||
MatrixApiRequestData *matrix_api_room_set_public(MatrixConnectionData *conn, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still needs docs
@@ -865,6 +865,49 @@ void matrix_room_handle_timeline_event(PurpleConversation *conv, | |||
g_free(escaped_body); | |||
} | |||
|
|||
/** | |||
* Callback for after the room is created to tweak it to publically accessible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should be able to do that in one step. set "visibility": "public"
in the body of the createRoom
request.
if (errcodestr && !strcmp(errcodestr, "M_NOT_FOUND")) { | ||
snprintf(roomid, strlen(errorstr) - 20, "%s", &errorstr[11]); | ||
roomid[strlen(errorstr) - 20] = '\0'; | ||
room_alias = g_strdup(roomid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this freed? (And why is taking a copy necessary anyway?)
This is a separate PR but requires the previous one as it builds upon join room. Addresses issue #26