Compare commits

...

3 Commits

Author SHA1 Message Date
Artem Savkov 607f9887ca Fix empty gateway->path with glib > 2.68
Starting with glib 2.69 g_match_info_fetch() returns an empty string
instead of NULL in case when no match was found. Properly handle this
case.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2021-09-28 18:38:48 +02:00
Artem Savkov eb768b4a81 Additional debuginfo on websocket upgrade
As mentioned in #226 there is some issue with newer glib versions. Add
the dump of our request for websocket upgrade to see if that'll make
things clearer.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2021-09-28 16:13:14 +02:00
Artem Savkov 068ed17a75 Basic implementation of discord's replies
No configuration, no proper parsing of the replied to message, nothing.
This is a quick and dirty implementation for replies. On reply this will
display the first 50 characters of the replied to message along with
original authors name and hardcoded IN_REPLY_TO prefix.

Fixes: #215

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2021-08-19 13:47:12 +02:00
3 changed files with 16 additions and 0 deletions

View File

@ -601,6 +601,7 @@ static gboolean discord_prepare_message(struct im_connection *ic,
gboolean posted = FALSE;
gchar *msg = json_o_strdup(minfo, "content");
json_value *jpinned = json_o_get(minfo, "pinned");
json_value *ref = json_o_get(minfo, "referenced_message");
gboolean pinned = (jpinned != NULL && jpinned->type == json_boolean) ?
jpinned->u.boolean : FALSE;
@ -618,6 +619,16 @@ static gboolean discord_prepare_message(struct im_connection *ic,
return FALSE;
}
if (ref != NULL && ref->type == json_object) {
gchar *rauthor = discord_canonize_name(json_o_str(json_o_get(ref,
"author"), "username"));
gchar *rmsg = g_strdup_printf("IN_REPLY_TO: %s> %.50s...", rauthor,
json_o_str(ref, "content"));
posted = discord_post_message(cinfo, author, rmsg, is_self, tstamp);
g_free(rmsg);
g_free(rauthor);
}
if (pinned == TRUE) {
gchar *newmsg = g_strconcat("PINNED: ", msg, NULL);
g_free(msg);

View File

@ -175,6 +175,9 @@ static void discord_http_gateway_cb(struct http_request *req)
if (dd->gateway->path == NULL) {
dd->gateway->path = g_strdup("/?encoding=json&v=6");
} else if (g_strcmp0(dd->gateway->path, "") == 0) {
g_free(dd->gateway->path);
dd->gateway->path = g_strdup("/?encoding=json&v=6");
}
g_match_info_free(match);

View File

@ -360,6 +360,8 @@ static gboolean discord_ws_connected_cb(gpointer data, int retcode,
g_free(bkey);
discord_debug(">>> (%s) %s %"G_GSIZE_FORMAT"\n%s\n", dd->uname, __func__, req->len, req->str);
dd->sslfd = ssl_getfd(source);
dd->inpa = b_input_add(dd->sslfd, B_EV_IO_READ, discord_ws_in_cb, ic);
ssl_write(dd->ssl, req->str, req->len);