Skip to content
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

Closed
wants to merge 2 commits into from
Closed

Create room #30

wants to merge 2 commits into from

Conversation

zamaudio
Copy link
Contributor

@zamaudio zamaudio commented Jan 19, 2017

This is a separate PR but requires the previous one as it builds upon join room. Addresses issue #26

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>
@richvdh richvdh self-assigned this Jan 20, 2017
Copy link
Member

@richvdh richvdh left a 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,
Copy link
Member

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];
Copy link
Member

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]);
Copy link
Member

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.

Copy link
Member

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,
Copy link
Member

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,
Copy link
Member

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
Copy link
Member

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);
Copy link
Member

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?)

@richvdh richvdh assigned zamaudio and unassigned richvdh Jan 23, 2017
@zamaudio zamaudio closed this Jan 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants