|
@@ -155,12 +155,24 @@ void flip_social_callback_draw_compose(Canvas *canvas, void *model)
|
|
|
FURI_LOG_E(TAG, "FlipSocialApp is NULL");
|
|
FURI_LOG_E(TAG, "FlipSocialApp is NULL");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ if (!selected_message)
|
|
|
|
|
+ {
|
|
|
|
|
+ FURI_LOG_E(TAG, "Selected message is NULL");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (strlen(selected_message) > MAX_MESSAGE_LENGTH)
|
|
|
|
|
+ {
|
|
|
|
|
+ FURI_LOG_E(TAG, "Message is too long");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (!flip_social_dialog_shown)
|
|
if (!flip_social_dialog_shown)
|
|
|
{
|
|
{
|
|
|
flip_social_dialog_shown = true;
|
|
flip_social_dialog_shown = true;
|
|
|
app_instance->input_event_queue = furi_record_open(RECORD_INPUT_EVENTS);
|
|
app_instance->input_event_queue = furi_record_open(RECORD_INPUT_EVENTS);
|
|
|
app_instance->input_event = furi_pubsub_subscribe(app_instance->input_event_queue, on_input, NULL);
|
|
app_instance->input_event = furi_pubsub_subscribe(app_instance->input_event_queue, on_input, NULL);
|
|
|
|
|
+ auth_headers_alloc();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
draw_user_message(canvas, selected_message, 0, 2);
|
|
draw_user_message(canvas, selected_message, 0, 2);
|
|
@@ -184,17 +196,20 @@ void flip_social_callback_draw_compose(Canvas *canvas, void *model)
|
|
|
// send selected_message
|
|
// send selected_message
|
|
|
if (selected_message && app_instance->login_username_logged_in)
|
|
if (selected_message && app_instance->login_username_logged_in)
|
|
|
{
|
|
{
|
|
|
|
|
+ if (strlen(selected_message) > MAX_MESSAGE_LENGTH)
|
|
|
|
|
+ {
|
|
|
|
|
+ FURI_LOG_E(TAG, "Message is too long");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
// Send the selected_message
|
|
// Send the selected_message
|
|
|
char command[256];
|
|
char command[256];
|
|
|
snprintf(command, sizeof(command), "{\"username\":\"%s\",\"content\":\"%s\"}",
|
|
snprintf(command, sizeof(command), "{\"username\":\"%s\",\"content\":\"%s\"}",
|
|
|
app_instance->login_username_logged_in, selected_message);
|
|
app_instance->login_username_logged_in, selected_message);
|
|
|
|
|
|
|
|
- bool success = flipper_http_post_request_with_headers(
|
|
|
|
|
- "https://www.flipsocial.net/api/feed/post/",
|
|
|
|
|
- "{\"Content-Type\":\"application/json\"}",
|
|
|
|
|
- command);
|
|
|
|
|
-
|
|
|
|
|
- if (!success)
|
|
|
|
|
|
|
+ if (!flipper_http_post_request_with_headers(
|
|
|
|
|
+ "https://www.flipsocial.net/api/feed/post/",
|
|
|
|
|
+ auth_headers,
|
|
|
|
|
+ command))
|
|
|
{
|
|
{
|
|
|
FURI_LOG_E(TAG, "Failed to send HTTP request for feed");
|
|
FURI_LOG_E(TAG, "Failed to send HTTP request for feed");
|
|
|
fhttp.state = ISSUE;
|
|
fhttp.state = ISSUE;
|
|
@@ -209,24 +224,13 @@ void flip_social_callback_draw_compose(Canvas *canvas, void *model)
|
|
|
FURI_LOG_E(TAG, "Message or username is NULL");
|
|
FURI_LOG_E(TAG, "Message or username is NULL");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- int i = 0;
|
|
|
|
|
while (fhttp.state == RECEIVING && furi_timer_is_running(fhttp.get_timeout_timer) > 0)
|
|
while (fhttp.state == RECEIVING && furi_timer_is_running(fhttp.get_timeout_timer) > 0)
|
|
|
{
|
|
{
|
|
|
// Wait for the feed to be received
|
|
// Wait for the feed to be received
|
|
|
furi_delay_ms(100);
|
|
furi_delay_ms(100);
|
|
|
|
|
|
|
|
- char dots_str[64] = "Receiving";
|
|
|
|
|
-
|
|
|
|
|
- // Append dots to the string based on the value of i
|
|
|
|
|
- int dot_count = i % 4;
|
|
|
|
|
- int len = strlen(dots_str);
|
|
|
|
|
- snprintf(dots_str + len, sizeof(dots_str) - len, "%.*s", dot_count, "....");
|
|
|
|
|
-
|
|
|
|
|
// Draw the resulting string on the canvas
|
|
// Draw the resulting string on the canvas
|
|
|
- canvas_draw_str(canvas, 0, 30, dots_str);
|
|
|
|
|
-
|
|
|
|
|
- i++;
|
|
|
|
|
|
|
+ canvas_draw_str(canvas, 0, 30, "Receiving..");
|
|
|
}
|
|
}
|
|
|
flip_social_dialog_stop = true;
|
|
flip_social_dialog_stop = true;
|
|
|
furi_timer_stop(fhttp.get_timeout_timer);
|
|
furi_timer_stop(fhttp.get_timeout_timer);
|
|
@@ -411,6 +415,7 @@ void flip_social_callback_draw_feed(Canvas *canvas, void *model)
|
|
|
flip_social_dialog_shown = true;
|
|
flip_social_dialog_shown = true;
|
|
|
app_instance->input_event_queue = furi_record_open(RECORD_INPUT_EVENTS);
|
|
app_instance->input_event_queue = furi_record_open(RECORD_INPUT_EVENTS);
|
|
|
app_instance->input_event = furi_pubsub_subscribe(app_instance->input_event_queue, on_input, NULL);
|
|
app_instance->input_event = furi_pubsub_subscribe(app_instance->input_event_queue, on_input, NULL);
|
|
|
|
|
+ auth_headers_alloc();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// handle action
|
|
// handle action
|
|
@@ -460,7 +465,7 @@ void flip_social_callback_draw_feed(Canvas *canvas, void *model)
|
|
|
}
|
|
}
|
|
|
char payload[256];
|
|
char payload[256];
|
|
|
snprintf(payload, sizeof(payload), "{\"username\":\"%s\",\"post_id\":\"%u\"}", app_instance->login_username_logged_in, flip_social_feed->ids[flip_social_feed->index]);
|
|
snprintf(payload, sizeof(payload), "{\"username\":\"%s\",\"post_id\":\"%u\"}", app_instance->login_username_logged_in, flip_social_feed->ids[flip_social_feed->index]);
|
|
|
- flipper_http_post_request_with_headers("https://www.flipsocial.net/api/feed/flip/", "{\"Content-Type\":\"application/json\"}", payload);
|
|
|
|
|
|
|
+ flipper_http_post_request_with_headers("https://www.flipsocial.net/api/feed/flip/", auth_headers, payload);
|
|
|
flip_social_canvas_draw_message(canvas, flip_social_feed->usernames[flip_social_feed->index], flip_social_feed->messages[flip_social_feed->index], flip_social_feed->is_flipped[flip_social_feed->index], flip_social_feed->index > 0, flip_social_feed->index < flip_social_feed->count - 1, flip_social_feed->flips[flip_social_feed->index]);
|
|
flip_social_canvas_draw_message(canvas, flip_social_feed->usernames[flip_social_feed->index], flip_social_feed->messages[flip_social_feed->index], flip_social_feed->is_flipped[flip_social_feed->index], flip_social_feed->index > 0, flip_social_feed->index < flip_social_feed->count - 1, flip_social_feed->flips[flip_social_feed->index]);
|
|
|
action = ActionNone;
|
|
action = ActionNone;
|
|
|
break;
|
|
break;
|
|
@@ -522,7 +527,7 @@ void flip_social_callback_draw_login(Canvas *canvas, void *model)
|
|
|
|
|
|
|
|
char buffer[256];
|
|
char buffer[256];
|
|
|
snprintf(buffer, sizeof(buffer), "{\"username\":\"%s\",\"password\":\"%s\"}", app_instance->login_username_logged_out, app_instance->login_password_logged_out);
|
|
snprintf(buffer, sizeof(buffer), "{\"username\":\"%s\",\"password\":\"%s\"}", app_instance->login_username_logged_out, app_instance->login_password_logged_out);
|
|
|
- flip_social_login_success = flipper_http_post_request_with_headers("https://www.flipsocial.net/api/user/login/", "{\"Content-Type\":\"application/json\"}", buffer);
|
|
|
|
|
|
|
+ flip_social_login_success = flipper_http_post_request_with_headers("https://www.flipsocial.net/api/user/login/", buffer, buffer);
|
|
|
if (flip_social_login_success)
|
|
if (flip_social_login_success)
|
|
|
{
|
|
{
|
|
|
fhttp.state = RECEIVING;
|
|
fhttp.state = RECEIVING;
|
|
@@ -687,6 +692,9 @@ void flip_social_callback_draw_register(Canvas *canvas, void *model)
|
|
|
|
|
|
|
|
app_instance->is_logged_in = "true";
|
|
app_instance->is_logged_in = "true";
|
|
|
|
|
|
|
|
|
|
+ // update header credentials
|
|
|
|
|
+ auth_headers_alloc();
|
|
|
|
|
+
|
|
|
// save the credentials
|
|
// save the credentials
|
|
|
save_settings(app_instance->wifi_ssid_logged_out, app_instance->wifi_password_logged_out, app_instance->login_username_logged_out, app_instance->login_username_logged_in, app_instance->login_password_logged_out, app_instance->change_password_logged_in, app_instance->is_logged_in);
|
|
save_settings(app_instance->wifi_ssid_logged_out, app_instance->wifi_password_logged_out, app_instance->login_username_logged_out, app_instance->login_username_logged_in, app_instance->login_password_logged_out, app_instance->change_password_logged_in, app_instance->is_logged_in);
|
|
|
|
|
|
|
@@ -768,6 +776,7 @@ void flip_social_callback_draw_explore(Canvas *canvas, void *model)
|
|
|
flip_social_dialog_shown = true;
|
|
flip_social_dialog_shown = true;
|
|
|
app_instance->input_event_queue = furi_record_open(RECORD_INPUT_EVENTS);
|
|
app_instance->input_event_queue = furi_record_open(RECORD_INPUT_EVENTS);
|
|
|
app_instance->input_event = furi_pubsub_subscribe(app_instance->input_event_queue, on_input, NULL);
|
|
app_instance->input_event = furi_pubsub_subscribe(app_instance->input_event_queue, on_input, NULL);
|
|
|
|
|
+ auth_headers_alloc();
|
|
|
}
|
|
}
|
|
|
flip_social_canvas_draw_explore(canvas, flip_social_explore->usernames[flip_social_explore->index], last_explore_response);
|
|
flip_social_canvas_draw_explore(canvas, flip_social_explore->usernames[flip_social_explore->index], last_explore_response);
|
|
|
|
|
|
|
@@ -778,7 +787,7 @@ void flip_social_callback_draw_explore(Canvas *canvas, void *model)
|
|
|
// add friend
|
|
// add friend
|
|
|
char add_payload[128];
|
|
char add_payload[128];
|
|
|
snprintf(add_payload, sizeof(add_payload), "{\"username\":\"%s\",\"friend\":\"%s\"}", app_instance->login_username_logged_in, flip_social_explore->usernames[flip_social_explore->index]);
|
|
snprintf(add_payload, sizeof(add_payload), "{\"username\":\"%s\",\"friend\":\"%s\"}", app_instance->login_username_logged_in, flip_social_explore->usernames[flip_social_explore->index]);
|
|
|
- flipper_http_post_request_with_headers("https://www.flipsocial.net/api/user/add-friend/", "{\"Content-Type\":\"application/json\"}", add_payload);
|
|
|
|
|
|
|
+ flipper_http_post_request_with_headers("https://www.flipsocial.net/api/user/add-friend/", auth_headers, add_payload);
|
|
|
canvas_clear(canvas);
|
|
canvas_clear(canvas);
|
|
|
flip_social_canvas_draw_explore(canvas, flip_social_explore->usernames[flip_social_explore->index], "Added!");
|
|
flip_social_canvas_draw_explore(canvas, flip_social_explore->usernames[flip_social_explore->index], "Added!");
|
|
|
action = ActionNone;
|
|
action = ActionNone;
|
|
@@ -787,7 +796,7 @@ void flip_social_callback_draw_explore(Canvas *canvas, void *model)
|
|
|
// remove friend
|
|
// remove friend
|
|
|
char remove_payload[128];
|
|
char remove_payload[128];
|
|
|
snprintf(remove_payload, sizeof(remove_payload), "{\"username\":\"%s\",\"friend\":\"%s\"}", app_instance->login_username_logged_in, flip_social_explore->usernames[flip_social_explore->index]);
|
|
snprintf(remove_payload, sizeof(remove_payload), "{\"username\":\"%s\",\"friend\":\"%s\"}", app_instance->login_username_logged_in, flip_social_explore->usernames[flip_social_explore->index]);
|
|
|
- flipper_http_post_request_with_headers("https://www.flipsocial.net/api/user/remove-friend/", "{\"Content-Type\":\"application/json\"}", remove_payload);
|
|
|
|
|
|
|
+ flipper_http_post_request_with_headers("https://www.flipsocial.net/api/user/remove-friend/", auth_headers, remove_payload);
|
|
|
canvas_clear(canvas);
|
|
canvas_clear(canvas);
|
|
|
flip_social_canvas_draw_explore(canvas, flip_social_explore->usernames[flip_social_explore->index], "Removed!");
|
|
flip_social_canvas_draw_explore(canvas, flip_social_explore->usernames[flip_social_explore->index], "Removed!");
|
|
|
action = ActionNone;
|
|
action = ActionNone;
|
|
@@ -833,6 +842,7 @@ void flip_social_callback_draw_friends(Canvas *canvas, void *model)
|
|
|
flip_social_dialog_shown = true;
|
|
flip_social_dialog_shown = true;
|
|
|
app_instance->input_event_queue = furi_record_open(RECORD_INPUT_EVENTS);
|
|
app_instance->input_event_queue = furi_record_open(RECORD_INPUT_EVENTS);
|
|
|
app_instance->input_event = furi_pubsub_subscribe(app_instance->input_event_queue, on_input, NULL);
|
|
app_instance->input_event = furi_pubsub_subscribe(app_instance->input_event_queue, on_input, NULL);
|
|
|
|
|
+ auth_headers_alloc();
|
|
|
}
|
|
}
|
|
|
flip_social_canvas_draw_explore(canvas, flip_social_friends->usernames[flip_social_friends->index], last_explore_response);
|
|
flip_social_canvas_draw_explore(canvas, flip_social_friends->usernames[flip_social_friends->index], last_explore_response);
|
|
|
|
|
|
|
@@ -843,7 +853,7 @@ void flip_social_callback_draw_friends(Canvas *canvas, void *model)
|
|
|
// add friend
|
|
// add friend
|
|
|
char add_payload[128];
|
|
char add_payload[128];
|
|
|
snprintf(add_payload, sizeof(add_payload), "{\"username\":\"%s\",\"friend\":\"%s\"}", app_instance->login_username_logged_in, flip_social_friends->usernames[flip_social_friends->index]);
|
|
snprintf(add_payload, sizeof(add_payload), "{\"username\":\"%s\",\"friend\":\"%s\"}", app_instance->login_username_logged_in, flip_social_friends->usernames[flip_social_friends->index]);
|
|
|
- if (flipper_http_post_request_with_headers("https://www.flipsocial.net/api/user/add-friend/", "{\"Content-Type\":\"application/json\"}", add_payload))
|
|
|
|
|
|
|
+ if (flipper_http_post_request_with_headers("https://www.flipsocial.net/api/user/add-friend/", auth_headers, add_payload))
|
|
|
{
|
|
{
|
|
|
canvas_clear(canvas);
|
|
canvas_clear(canvas);
|
|
|
flip_social_canvas_draw_explore(canvas, flip_social_friends->usernames[flip_social_friends->index], "Added!");
|
|
flip_social_canvas_draw_explore(canvas, flip_social_friends->usernames[flip_social_friends->index], "Added!");
|
|
@@ -862,7 +872,7 @@ void flip_social_callback_draw_friends(Canvas *canvas, void *model)
|
|
|
// remove friend
|
|
// remove friend
|
|
|
char remove_payload[128];
|
|
char remove_payload[128];
|
|
|
snprintf(remove_payload, sizeof(remove_payload), "{\"username\":\"%s\",\"friend\":\"%s\"}", app_instance->login_username_logged_in, flip_social_friends->usernames[flip_social_friends->index]);
|
|
snprintf(remove_payload, sizeof(remove_payload), "{\"username\":\"%s\",\"friend\":\"%s\"}", app_instance->login_username_logged_in, flip_social_friends->usernames[flip_social_friends->index]);
|
|
|
- if (flipper_http_post_request_with_headers("https://www.flipsocial.net/api/user/remove-friend/", "{\"Content-Type\":\"application/json\"}", remove_payload))
|
|
|
|
|
|
|
+ if (flipper_http_post_request_with_headers("https://www.flipsocial.net/api/user/remove-friend/", auth_headers, remove_payload))
|
|
|
{
|
|
{
|
|
|
canvas_clear(canvas);
|
|
canvas_clear(canvas);
|
|
|
flip_social_canvas_draw_explore(canvas, flip_social_friends->usernames[flip_social_friends->index], "Removed!");
|
|
flip_social_canvas_draw_explore(canvas, flip_social_friends->usernames[flip_social_friends->index], "Removed!");
|