core: Refresh identity info so that you see your name at the top right when editing your profile in ssb.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 9m34s
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 9m34s
This commit is contained in:
37
src/ssb.db.c
37
src/ssb.db.c
@@ -623,6 +623,12 @@ static char* _tf_ssb_db_get_message_blob_wants(sqlite3* db, int64_t rowid)
|
||||
return result;
|
||||
}
|
||||
|
||||
typedef enum _message_type_t
|
||||
{
|
||||
k_message_type_other,
|
||||
k_message_type_post,
|
||||
} message_type_t;
|
||||
|
||||
typedef struct _message_store_t
|
||||
{
|
||||
char id[k_id_base64_len];
|
||||
@@ -635,6 +641,7 @@ typedef struct _message_store_t
|
||||
const char* content;
|
||||
size_t length;
|
||||
|
||||
message_type_t type;
|
||||
bool out_stored;
|
||||
char* out_blob_wants;
|
||||
|
||||
@@ -717,26 +724,25 @@ static void _tf_ssb_db_store_message_after_work(tf_ssb_t* ssb, int status, void*
|
||||
}
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
JSContext* context = tf_ssb_get_context(ssb);
|
||||
JSValue content = JS_ParseJSON(context, store->content, strlen(store->content), NULL);
|
||||
if (JS_IsObject(content))
|
||||
if (store->type == k_message_type_post)
|
||||
{
|
||||
JSValue type_value = JS_GetPropertyStr(context, content, "type");
|
||||
const char* type = JS_ToCString(context, type_value);
|
||||
if (type && strcmp(type, "post") == 0)
|
||||
JSContext* context = tf_ssb_get_context(ssb);
|
||||
JSValue content = JS_ParseJSON(context, store->content, strlen(store->content), NULL);
|
||||
if (JS_IsObject(content))
|
||||
{
|
||||
JSValue type_value = JS_GetPropertyStr(context, content, "type");
|
||||
const char* type = JS_ToCString(context, type_value);
|
||||
JSValue text_value = JS_GetPropertyStr(context, content, "text");
|
||||
const char* text = JS_ToCString(context, text_value);
|
||||
|
||||
void tf_notify_message_added_ios(const char* identifier, const char* title, const char* content);
|
||||
tf_notify_message_added_ios(store->id, type, text);
|
||||
JS_FreeCString(context, text);
|
||||
JS_FreeValue(context, text_value);
|
||||
JS_FreeCString(context, type);
|
||||
JS_FreeValue(context, type_value);
|
||||
}
|
||||
JS_FreeCString(context, type);
|
||||
JS_FreeValue(context, type_value);
|
||||
JS_FreeValue(context, content);
|
||||
}
|
||||
JS_FreeValue(context, content);
|
||||
#endif
|
||||
|
||||
if (store->callback)
|
||||
@@ -800,6 +806,16 @@ void tf_ssb_db_store_message(
|
||||
JS_FreeValue(context, timestampval);
|
||||
|
||||
JSValue contentval = JS_GetPropertyStr(context, val, "content");
|
||||
JSValue typeval = JS_IsObject(contentval) ? JS_GetPropertyStr(context, contentval, "type") : JS_UNDEFINED;
|
||||
const char* type = JS_IsString(typeval) ? JS_ToCString(context, typeval) : NULL;
|
||||
message_type_t message_type = k_message_type_other;
|
||||
if (type)
|
||||
{
|
||||
message_type = strcmp(type, "post") == 0 ? k_message_type_post : k_message_type_other;
|
||||
}
|
||||
JS_FreeCString(context, type);
|
||||
JS_FreeValue(context, typeval);
|
||||
|
||||
JSValue content = JS_JSONStringify(context, contentval, JS_NULL, JS_NULL);
|
||||
size_t content_len;
|
||||
const char* contentstr = JS_ToCStringLen(context, &content_len, content);
|
||||
@@ -811,6 +827,7 @@ void tf_ssb_db_store_message(
|
||||
.sequence = sequence,
|
||||
.timestamp = timestamp,
|
||||
.content = contentstr,
|
||||
.type = message_type,
|
||||
.length = content_len,
|
||||
.flags = flags,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user