Skip to content

Commit c76b36b

Browse files
committed
Ignore empty stripped messages in /send_message2
Facebook API will return an error when we send empty messages or messages that only contain spaces. Here we just ignore them when the client sends them.
1 parent fcf1a1e commit c76b36b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

facebook/facebook-api.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2818,6 +2818,15 @@ fb_api_message_send(FbApi *api, FbApiMessage *msg)
28182818
g_free(json);
28192819
}
28202820

2821+
static gboolean
2822+
fb_api_is_message_not_empty(const gchar *text)
2823+
{
2824+
while (*text && *text == ' ') {
2825+
text++;
2826+
}
2827+
return *text != '\0';
2828+
}
2829+
28212830
void
28222831
fb_api_message(FbApi *api, FbId id, gboolean thread, const gchar *text)
28232832
{
@@ -2827,6 +2836,7 @@ fb_api_message(FbApi *api, FbId id, gboolean thread, const gchar *text)
28272836

28282837
g_return_if_fail(FB_IS_API(api));
28292838
g_return_if_fail(text != NULL);
2839+
g_return_if_fail(fb_api_is_message_not_empty(text));
28302840
priv = api->priv;
28312841

28322842
msg = fb_api_message_dup(NULL, FALSE);

0 commit comments

Comments
 (0)