forked from cory/tildefriends
		
	Fixing some stock experience issues.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3999 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
		| @@ -1 +1 @@ | |||||||
| {"type":"tildefriends-app","files":{"app.js":"&OMzy1V2Z53ARpvUnFZ1BxsQr/Z8oQmFC678s/Hh6Gtc=.sha256"}} | {"type":"tildefriends-app","files":{"app.js":"&qEJDfZ43KazIxiZl8OCKb2uaDOsPkxnIohEzQ1LLFpg=.sha256"}} | ||||||
| @@ -21,7 +21,7 @@ async function main() { | |||||||
| 			li.appendChild(a); | 			li.appendChild(a); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	populate_apps('apps', '${core.user.credentials.session.name}', ${JSON.stringify(apps)}); | 	populate_apps('apps', '${core.user.credentials?.session?.name}', ${JSON.stringify(apps)}); | ||||||
| 	populate_apps('core_apps', 'core', ${JSON.stringify(core_apps)}); | 	populate_apps('core_apps', 'core', ${JSON.stringify(core_apps)}); | ||||||
| </script> | </script> | ||||||
| </html>` | </html>` | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ var gProcesses = {}; | |||||||
| var gStatsTimer = false; | var gStatsTimer = false; | ||||||
|  |  | ||||||
| var gGlobalSettings = { | var gGlobalSettings = { | ||||||
| 	index: "/~core/index", | 	index: "/~core/apps/", | ||||||
| }; | }; | ||||||
|  |  | ||||||
| var kGlobalSettingsFile = "data/global/settings.json"; | var kGlobalSettingsFile = "data/global/settings.json"; | ||||||
|   | |||||||
| @@ -375,7 +375,7 @@ bool tf_ssb_db_blob_get(tf_ssb_t* ssb, const char* id, uint8_t** out_blob, size_ | |||||||
| 	return result; | 	return result; | ||||||
| } | } | ||||||
|  |  | ||||||
| bool tf_ssb_db_blob_store(tf_ssb_t* ssb, const uint8_t* blob, size_t size, char* out_id, size_t out_id_size) | bool tf_ssb_db_blob_store(tf_ssb_t* ssb, const uint8_t* blob, size_t size, char* out_id, size_t out_id_size, bool* out_new) | ||||||
| { | { | ||||||
| 	bool result = false; | 	bool result = false; | ||||||
| 	sqlite3* db = tf_ssb_get_db(ssb); | 	sqlite3* db = tf_ssb_get_db(ssb); | ||||||
| @@ -411,7 +411,7 @@ bool tf_ssb_db_blob_store(tf_ssb_t* ssb, const uint8_t* blob, size_t size, char* | |||||||
| 		printf("prepare failed: %s\n", sqlite3_errmsg(db)); | 		printf("prepare failed: %s\n", sqlite3_errmsg(db)); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (rows) | 	if (rows && !out_new) | ||||||
| 	{ | 	{ | ||||||
| 		printf("blob stored %s %zd => %d\n", id, size, result); | 		printf("blob stored %s %zd => %d\n", id, size, result); | ||||||
| 	} | 	} | ||||||
| @@ -432,6 +432,10 @@ bool tf_ssb_db_blob_store(tf_ssb_t* ssb, const uint8_t* blob, size_t size, char* | |||||||
| 	{ | 	{ | ||||||
| 		snprintf(out_id, out_id_size, "%s", id); | 		snprintf(out_id, out_id_size, "%s", id); | ||||||
| 	} | 	} | ||||||
|  | 	if (out_new) | ||||||
|  | 	{ | ||||||
|  | 		*out_new = rows != 0; | ||||||
|  | 	} | ||||||
| 	return result; | 	return result; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ void tf_ssb_db_init(tf_ssb_t* ssb); | |||||||
| bool tf_ssb_db_store_message(tf_ssb_t* ssb, JSContext* context, const char* id, JSValue val, const char* signature, bool sequence_before_author); | bool tf_ssb_db_store_message(tf_ssb_t* ssb, JSContext* context, const char* id, JSValue val, const char* signature, bool sequence_before_author); | ||||||
| bool tf_ssb_db_message_content_get(tf_ssb_t* ssb, const char* id, uint8_t** out_blob, size_t* out_size); | bool tf_ssb_db_message_content_get(tf_ssb_t* ssb, const char* id, uint8_t** out_blob, size_t* out_size); | ||||||
| bool tf_ssb_db_blob_get(tf_ssb_t* ssb, const char* id, uint8_t** out_blob, size_t* out_size); | bool tf_ssb_db_blob_get(tf_ssb_t* ssb, const char* id, uint8_t** out_blob, size_t* out_size); | ||||||
| bool tf_ssb_db_blob_store(tf_ssb_t* ssb, const uint8_t* blob, size_t size, char* out_id, size_t out_id_size); | bool tf_ssb_db_blob_store(tf_ssb_t* ssb, const uint8_t* blob, size_t size, char* out_id, size_t out_id_size, bool* out_new); | ||||||
|  |  | ||||||
| bool tf_ssb_db_get_message_by_author_and_sequence(tf_ssb_t* ssb, const char* author, int64_t sequence, char* out_message_id, size_t out_message_id_size, double* out_timestamp, char** out_content); | bool tf_ssb_db_get_message_by_author_and_sequence(tf_ssb_t* ssb, const char* author, int64_t sequence, char* out_message_id, size_t out_message_id_size, double* out_timestamp, char** out_content); | ||||||
| bool tf_ssb_db_get_latest_message_by_author(tf_ssb_t* ssb, const char* author, int64_t* out_sequence, char* out_message_id, size_t out_message_id_size); | bool tf_ssb_db_get_latest_message_by_author(tf_ssb_t* ssb, const char* author, int64_t* out_sequence, char* out_message_id, size_t out_message_id_size); | ||||||
|   | |||||||
| @@ -78,9 +78,13 @@ static void _tf_ssb_import_file_read(uv_fs_t* req) | |||||||
| 	char id[k_id_base64_len]; | 	char id[k_id_base64_len]; | ||||||
| 	if (req->result >= 0) | 	if (req->result >= 0) | ||||||
| 	{ | 	{ | ||||||
| 		if (tf_ssb_db_blob_store(file->ssb, (const uint8_t*)file->data, req->result, id, sizeof(id))) | 		bool is_new = false; | ||||||
|  | 		if (tf_ssb_db_blob_store(file->ssb, (const uint8_t*)file->data, req->result, id, sizeof(id), &is_new)) | ||||||
| 		{ | 		{ | ||||||
| 			printf("Stored %s/%s as %s.\n", file->parent, file->name, id); | 			if (is_new) | ||||||
|  | 			{ | ||||||
|  | 				printf("Stored %s/%s as %s.\n", file->parent, file->name, id); | ||||||
|  | 			} | ||||||
| 			if (strcasecmp(file->name + strlen(file->name) - strlen(".json"), ".json") == 0) | 			if (strcasecmp(file->name + strlen(file->name) - strlen(".json"), ".json") == 0) | ||||||
| 			{ | 			{ | ||||||
| 				sqlite3_stmt* statement; | 				sqlite3_stmt* statement; | ||||||
| @@ -92,7 +96,10 @@ static void _tf_ssb_import_file_read(uv_fs_t* req) | |||||||
| 						sqlite3_bind_text(statement, 3, id, -1, NULL) == SQLITE_OK && | 						sqlite3_bind_text(statement, 3, id, -1, NULL) == SQLITE_OK && | ||||||
| 						sqlite3_step(statement) == SQLITE_DONE) | 						sqlite3_step(statement) == SQLITE_DONE) | ||||||
| 					{ | 					{ | ||||||
| 						printf("Registered %s path:%s as %s.\n", file->user, file->name, id); | 						if (sqlite3_changes(tf_ssb_get_db(file->ssb))) | ||||||
|  | 						{ | ||||||
|  | 							printf("Registered %s path:%s as %s.\n", file->user, file->name, id); | ||||||
|  | 						} | ||||||
| 						_tf_ssb_import_add_app(file->ssb, file->user, file->name); | 						_tf_ssb_import_add_app(file->ssb, file->user, file->name); | ||||||
| 					} | 					} | ||||||
| 					sqlite3_finalize(statement); | 					sqlite3_finalize(statement); | ||||||
|   | |||||||
| @@ -178,7 +178,7 @@ static JSValue _tf_ssb_blobStore(JSContext* context, JSValueConst this_val, int | |||||||
| 		if (JS_IsString(argv[0])) | 		if (JS_IsString(argv[0])) | ||||||
| 		{ | 		{ | ||||||
| 			const char* text = JS_ToCStringLen(context, &size, argv[0]); | 			const char* text = JS_ToCStringLen(context, &size, argv[0]); | ||||||
| 			if (tf_ssb_db_blob_store(ssb, (const uint8_t*)text, size, id, sizeof(id))) | 			if (tf_ssb_db_blob_store(ssb, (const uint8_t*)text, size, id, sizeof(id), NULL)) | ||||||
| 			{ | 			{ | ||||||
| 				result = JS_NewString(context, id); | 				result = JS_NewString(context, id); | ||||||
| 			} | 			} | ||||||
| @@ -186,7 +186,7 @@ static JSValue _tf_ssb_blobStore(JSContext* context, JSValueConst this_val, int | |||||||
| 		} | 		} | ||||||
| 		else if ((blob = tf_util_try_get_array_buffer(context, &size, argv[0])) != 0) | 		else if ((blob = tf_util_try_get_array_buffer(context, &size, argv[0])) != 0) | ||||||
| 		{ | 		{ | ||||||
| 			if (tf_ssb_db_blob_store(ssb, blob, size, id, sizeof(id))) | 			if (tf_ssb_db_blob_store(ssb, blob, size, id, sizeof(id), NULL)) | ||||||
| 			{ | 			{ | ||||||
| 				result = JS_NewString(context, id); | 				result = JS_NewString(context, id); | ||||||
| 			} | 			} | ||||||
| @@ -201,7 +201,7 @@ static JSValue _tf_ssb_blobStore(JSContext* context, JSValueConst this_val, int | |||||||
| 				blob = tf_util_try_get_array_buffer(context, &size, buffer); | 				blob = tf_util_try_get_array_buffer(context, &size, buffer); | ||||||
| 				if (blob) | 				if (blob) | ||||||
| 				{ | 				{ | ||||||
| 					if (tf_ssb_db_blob_store(ssb, blob, size, id, sizeof(id))) | 					if (tf_ssb_db_blob_store(ssb, blob, size, id, sizeof(id), NULL)) | ||||||
| 					{ | 					{ | ||||||
| 						result = JS_NewString(context, id); | 						result = JS_NewString(context, id); | ||||||
| 					} | 					} | ||||||
|   | |||||||
| @@ -156,7 +156,7 @@ void tf_ssb_test_ssb(const tf_test_options_t* options) | |||||||
|  |  | ||||||
| 	char blob_id[k_id_base64_len] = { 0 }; | 	char blob_id[k_id_base64_len] = { 0 }; | ||||||
| 	const char* k_blob = "Hello, blob!"; | 	const char* k_blob = "Hello, blob!"; | ||||||
| 	b = tf_ssb_db_blob_store(ssb0, (const uint8_t*)k_blob, strlen(k_blob), blob_id, sizeof(blob_id)); | 	b = tf_ssb_db_blob_store(ssb0, (const uint8_t*)k_blob, strlen(k_blob), blob_id, sizeof(blob_id), NULL); | ||||||
| 	assert(b); | 	assert(b); | ||||||
|  |  | ||||||
| 	tf_ssb_append_post(ssb0, "Hello, world!"); | 	tf_ssb_append_post(ssb0, "Hello, world!"); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user