forked from cory/tildefriends
		
	Compare commits
	
		
			16 Commits
		
	
	
		
			24c720c79a
			...
			tasiaiso-n
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 3b36496dac | |||
| 4ebd6c24a9 | |||
| 05451d98b3 | |||
| 22a4bce3c8 | |||
| 76d499f00b | |||
| f0772f9b99 | |||
| 46e711f0a5 | |||
| abffac3f82 | |||
| 27b275548e | |||
| 93ce253d1e | |||
| a5af312b39 | |||
| 4b5e8e8a43 | |||
| 443dd4d168 | |||
| 907479df84 | |||
| 9887a78e98 | |||
| f669371349 | 
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -8,3 +8,4 @@ out | |||||||
| *.swo | *.swo | ||||||
| *.swp | *.swp | ||||||
| .zsign_cache/ | .zsign_cache/ | ||||||
|  | result | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| { | { | ||||||
| 	"type": "tildefriends-app", | 	"type": "tildefriends-app", | ||||||
| 	"emoji": "🐌", | 	"emoji": "🐌", | ||||||
| 	"previous": "&raSj7ozmSDNGmB6TtjDk7oOiTc33ZN+RrBMASJ2F4cA=.sha256" | 	"previous": "&wA6sLaDxtYeFdVCCu8jyhPsGYtGZEjbWQHeGOn0Yifg=.sha256" | ||||||
| } | } | ||||||
|   | |||||||
| @@ -345,13 +345,15 @@ class TfElement extends LitElement { | |||||||
| 					([k, v]) => html` | 					([k, v]) => html` | ||||||
| 						<button | 						<button | ||||||
| 							title=${v} | 							title=${v} | ||||||
| 							class="w3-bar-item w3-padding-large w3-hover-theme tab ${self.tab == | 							class="w3-bar-item w3-padding w3-hover-theme tab ${self.tab == v | ||||||
| 							v |  | ||||||
| 								? 'w3-theme-l2' | 								? 'w3-theme-l2' | ||||||
| 								: 'w3-theme-l1'}" | 								: 'w3-theme-l1'}" | ||||||
| 							@click=${() => self.set_tab(v)} | 							@click=${() => self.set_tab(v)} | ||||||
| 						> | 						> | ||||||
| 							${k} | 							${k} | ||||||
|  | 							<span class=${self.tab == v ? '' : 'w3-hide-small'} | ||||||
|  | 								>${v.charAt(0).toUpperCase() + v.substring(1)}</span | ||||||
|  | 							> | ||||||
| 						</button> | 						</button> | ||||||
| 					` | 					` | ||||||
| 				)} | 				)} | ||||||
|   | |||||||
| @@ -105,6 +105,16 @@ class TfTabConnectionsElement extends LitElement { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	render_connection(connection) { | 	render_connection(connection) { | ||||||
|  | 		let requests = Object.values( | ||||||
|  | 			connection.requests.reduce(function (accumulator, value) { | ||||||
|  | 				let key = `${value.name}:${Math.sign(value.request_number)}`; | ||||||
|  | 				if (!accumulator[key]) { | ||||||
|  | 					accumulator[key] = Object.assign({count: 0}, value); | ||||||
|  | 				} | ||||||
|  | 				accumulator[key].count++; | ||||||
|  | 				return accumulator; | ||||||
|  | 			}, {}) | ||||||
|  | 		); | ||||||
| 		return html` | 		return html` | ||||||
| 			<button | 			<button | ||||||
| 				class="w3-button w3-theme-d1" | 				class="w3-button w3-theme-d1" | ||||||
| @@ -117,10 +127,15 @@ class TfTabConnectionsElement extends LitElement { | |||||||
| 				? '🚇' | 				? '🚇' | ||||||
| 				: html`(${connection.host}:${connection.port})`} | 				: html`(${connection.host}:${connection.port})`} | ||||||
| 			<div> | 			<div> | ||||||
| 				${connection.requests.map( | 				${requests.map( | ||||||
| 					(x) => html` | 					(x) => html` | ||||||
| 						<span class="w3-tag w3-small" | 						<span class="w3-tag w3-small" | ||||||
| 							>${x.request_number > 0 ? '🟩' : '🟥'} ${x.name}</span | 							>${x.request_number > 0 ? '🟩' : '🟥'} ${x.name} | ||||||
|  | 							<span | ||||||
|  | 								class="w3-badge w3-white" | ||||||
|  | 								style=${x.count > 1 ? undefined : 'display: none'} | ||||||
|  | 								>${x.count}</span | ||||||
|  | 							></span | ||||||
| 						> | 						> | ||||||
| 					` | 					` | ||||||
| 				)} | 				)} | ||||||
| @@ -193,12 +208,16 @@ class TfTabConnectionsElement extends LitElement { | |||||||
| 					${this.identities.map( | 					${this.identities.map( | ||||||
| 						(x) => | 						(x) => | ||||||
| 							html`<li class="w3-bar"> | 							html`<li class="w3-bar"> | ||||||
| 								${x == this.server_identity ? | 								${x == this.server_identity | ||||||
| 									html`<span class="w3-tag w3-medium w3-round w3-theme-l1">🖥 local server</span>` : | 									? html`<span class="w3-tag w3-medium w3-round w3-theme-l1" | ||||||
| 									undefined} | 											>🖥 local server</span | ||||||
| 								${this.my_identities.indexOf(x) != -1 ? | 										>` | ||||||
| 									html`<span class="w3-tag w3-medium w3-round w3-theme-d1">😎 you</span>` : | 									: undefined} | ||||||
| 									undefined} | 								${this.my_identities.indexOf(x) != -1 | ||||||
|  | 									? html`<span class="w3-tag w3-medium w3-round w3-theme-d1" | ||||||
|  | 											>😎 you</span | ||||||
|  | 										>` | ||||||
|  | 									: undefined} | ||||||
| 								<tf-user id=${x} .users=${this.users}></tf-user> | 								<tf-user id=${x} .users=${this.users}></tf-user> | ||||||
| 							</li>` | 							</li>` | ||||||
| 					)} | 					)} | ||||||
|   | |||||||
| @@ -115,12 +115,16 @@ class TfTabNewsElement extends LitElement { | |||||||
| 				></tf-profile>` | 				></tf-profile>` | ||||||
| 			: undefined; | 			: undefined; | ||||||
| 		let edit_profile; | 		let edit_profile; | ||||||
| 		if (!this.loading && | 		if ( | ||||||
|  | 			!this.loading && | ||||||
| 			this.users[this.whoami]?.name === undefined && | 			this.users[this.whoami]?.name === undefined && | ||||||
| 			this.hash.substring(1) != this.whoami) { | 			this.hash.substring(1) != this.whoami | ||||||
| 			edit_profile = html` | 		) { | ||||||
| 				<div class="w3-panel w3-padding w3-round w3-card-4 w3-theme-l3"> | 			edit_profile = html` <div | ||||||
| 					ℹ️ Follow your identity link ☝️ above to edit your profile and set your name. | 				class="w3-panel w3-padding w3-round w3-card-4 w3-theme-l3" | ||||||
|  | 			> | ||||||
|  | 				ℹ️ Follow your identity link ☝️ above to edit your profile and set your | ||||||
|  | 				name. | ||||||
| 			</div>`; | 			</div>`; | ||||||
| 		} | 		} | ||||||
| 		return html` | 		return html` | ||||||
|   | |||||||
| @@ -19,6 +19,10 @@ class TfUserElement extends LitElement { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	render() { | 	render() { | ||||||
|  | 		let image = html`<span | ||||||
|  | 			class="w3-theme-light w3-circle" | ||||||
|  | 			style="display: inline-block; width: 2em; height: 2em; text-align: center; line-height: 2em" | ||||||
|  | 		>?</span>`; | ||||||
| 		let name = this.users?.[this.id]?.name; | 		let name = this.users?.[this.id]?.name; | ||||||
| 		name = | 		name = | ||||||
| 			name !== undefined | 			name !== undefined | ||||||
| @@ -26,22 +30,21 @@ class TfUserElement extends LitElement { | |||||||
| 				: html`<a target="_top" href=${'#' + this.id}>${this.id}</a>`; | 				: html`<a target="_top" href=${'#' + this.id}>${this.id}</a>`; | ||||||
|  |  | ||||||
| 		if (this.users[this.id]) { | 		if (this.users[this.id]) { | ||||||
| 			let image = this.users[this.id].image; | 			let image_link = this.users[this.id].image; | ||||||
| 			image = typeof image == 'string' ? image : image?.link; | 			image_link = typeof image_link == 'string' ? image_link : image_link?.link; | ||||||
| 			return html` <div style="display: inline-block; font-weight: bold"> | 			if (image_link !== undefined) { | ||||||
| 				<img | 				image = html`<img | ||||||
| 					style="width: 2em; height: 2em; vertical-align: middle; border-radius: 50%" | 					class="w3-circle" | ||||||
| 					?hidden=${image === undefined} | 					style="width: 2em; height: 2em; vertical-align: middle" | ||||||
| 					src="${image ? '/' + image + '/view' : undefined}" | 					src="/${image_link}/view" | ||||||
| 				/> | 				/>`; | ||||||
| 				${name} |  | ||||||
| 			</div>`; |  | ||||||
| 		} else { |  | ||||||
| 			return html` <div style="display: inline-block; font-weight: bold"> |  | ||||||
| 				${name} |  | ||||||
| 			</div>`; |  | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  | 		return html` <div style="display: inline-block; font-weight: bold"> | ||||||
|  | 			${image} | ||||||
|  | 			${name} | ||||||
|  | 		</div>`; | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| customElements.define('tf-user', TfUserElement); | customElements.define('tf-user', TfUserElement); | ||||||
|   | |||||||
							
								
								
									
										68
									
								
								default.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								default.nix
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,68 @@ | |||||||
|  | # How to upgrade to a newer version | ||||||
|  | # - Comment `src.hash` | ||||||
|  | # - Change `version` | ||||||
|  | # - Run `$ nix build` | ||||||
|  | # This will fetch the source code | ||||||
|  | # Since `hash` is not provided, nix will stop building and throw an error: | ||||||
|  | # | ||||||
|  | # error: hash mismatch in fixed-output derivation '/nix/store/fghi3ljs6fhz8pwm3dh73j5fwjpq5wbz-source.drv': | ||||||
|  | #          specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= | ||||||
|  | #             got:    sha256-+uthA1w8CmZfW+WOK9wYGl2fUl/k10ufOc8W+Pwa9iQ= | ||||||
|  | # error: 1 dependencies of derivation '/nix/store/imcwsw5r74vkd8r0qa2k7cys2xfgraaz-tildefriends-0.0.18.drv' failed to build | ||||||
|  | # | ||||||
|  | # - Change `src.hash` to the new one, ie `sha256-+uthA1w8CmZfW+WOK9wYGl2fUl/k10ufOc8W+Pwa9iQ=` | ||||||
|  | # - Uncomment `src.hash` | ||||||
|  | # - Build again, this time it should work. | ||||||
|  | # - Check the release notes, if there's a new dependency or a change to `GNUMakefile`, this file might need to be changed too. | ||||||
|  | # For more details, contact tasiaiso @ https://tilde.club/~tasiaiso/ | ||||||
|  | # | ||||||
|  | # WARNING: currently it is pinned to `47838d5e482cb4aac40190fa0414f08b8cf94d40`. I couldn't get v0.0.18 to work for some reason. | ||||||
|  | # I'll change this in the next release - tasiaiso | ||||||
|  | { | ||||||
|  |   pkgs ? import <nixpkgs> {}, | ||||||
|  |   lib ? import <nixpkgs/lib>, | ||||||
|  | }: | ||||||
|  | pkgs.stdenv.mkDerivation rec { | ||||||
|  |   pname = "tildefriends"; | ||||||
|  |   version = "0.0.19"; | ||||||
|  |  | ||||||
|  |   src = pkgs.fetchFromGitea { | ||||||
|  |     domain = "dev.tildefriends.net"; | ||||||
|  |     owner = "cory"; | ||||||
|  |     repo = "tildefriends"; | ||||||
|  |     # rev = "v${version}"; | ||||||
|  |     rev = "47838d5e482cb4aac40190fa0414f08b8cf94d40"; | ||||||
|  |     hash = "sha256-mb5KYvWPIqgV64FOaXKHm2ownBJiiSRtdH8+YWiXwvE="; # 47838d5e482cb4aac40190fa0414f08b8cf94d40 | ||||||
|  |     fetchSubmodules = true; | ||||||
|  |   }; | ||||||
|  |  | ||||||
|  |   nativeBuildInputs = with pkgs; [ | ||||||
|  |     gnumake | ||||||
|  |     openssl | ||||||
|  |     which | ||||||
|  |   ]; | ||||||
|  |  | ||||||
|  |   buildInputs = with pkgs; [ | ||||||
|  |     openssl | ||||||
|  |     which | ||||||
|  |   ]; | ||||||
|  |  | ||||||
|  |   buildPhase = '' | ||||||
|  |     make -j $NIX_BUILD_CORES release | ||||||
|  |   ''; | ||||||
|  |  | ||||||
|  |   installPhase = '' | ||||||
|  |     mkdir -p $out/bin | ||||||
|  |     cp -r out/release/tildefriends $out/bin | ||||||
|  |   ''; | ||||||
|  |  | ||||||
|  |   doCheck = false; | ||||||
|  |  | ||||||
|  |   meta = with pkgs; { | ||||||
|  |     homepage = "https://tildefriends.net"; | ||||||
|  |     description = "Make apps and friends from the comfort of your web browser."; | ||||||
|  |     mainProgram = "tildefriends"; | ||||||
|  |     license = with lib.licenses; [mit]; | ||||||
|  |     platforms = lib.platforms.all; | ||||||
|  |   }; | ||||||
|  | } | ||||||
							
								
								
									
										61
									
								
								flake.lock
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								flake.lock
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,61 @@ | |||||||
|  | { | ||||||
|  |   "nodes": { | ||||||
|  |     "flake-utils": { | ||||||
|  |       "inputs": { | ||||||
|  |         "systems": "systems" | ||||||
|  |       }, | ||||||
|  |       "locked": { | ||||||
|  |         "lastModified": 1710146030, | ||||||
|  |         "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", | ||||||
|  |         "owner": "numtide", | ||||||
|  |         "repo": "flake-utils", | ||||||
|  |         "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", | ||||||
|  |         "type": "github" | ||||||
|  |       }, | ||||||
|  |       "original": { | ||||||
|  |         "owner": "numtide", | ||||||
|  |         "repo": "flake-utils", | ||||||
|  |         "type": "github" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "nixpkgs": { | ||||||
|  |       "locked": { | ||||||
|  |         "lastModified": 1715395895, | ||||||
|  |         "narHash": "sha256-DreMqi6+qa21ffLQqhMQL2XRUkAGt3N7iVB5FhJKie4=", | ||||||
|  |         "owner": "NixOS", | ||||||
|  |         "repo": "nixpkgs", | ||||||
|  |         "rev": "71bae31b7dbc335528ca7e96f479ec93462323ff", | ||||||
|  |         "type": "github" | ||||||
|  |       }, | ||||||
|  |       "original": { | ||||||
|  |         "owner": "NixOS", | ||||||
|  |         "ref": "nixos-23.11", | ||||||
|  |         "repo": "nixpkgs", | ||||||
|  |         "type": "github" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "root": { | ||||||
|  |       "inputs": { | ||||||
|  |         "flake-utils": "flake-utils", | ||||||
|  |         "nixpkgs": "nixpkgs" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "systems": { | ||||||
|  |       "locked": { | ||||||
|  |         "lastModified": 1681028828, | ||||||
|  |         "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", | ||||||
|  |         "owner": "nix-systems", | ||||||
|  |         "repo": "default", | ||||||
|  |         "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", | ||||||
|  |         "type": "github" | ||||||
|  |       }, | ||||||
|  |       "original": { | ||||||
|  |         "owner": "nix-systems", | ||||||
|  |         "repo": "default", | ||||||
|  |         "type": "github" | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   "root": "root", | ||||||
|  |   "version": 7 | ||||||
|  | } | ||||||
							
								
								
									
										37
									
								
								flake.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								flake.nix
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | |||||||
|  | { | ||||||
|  |   description = "Tilde Friends is a platform for making, running, and sharing web applications."; | ||||||
|  |  | ||||||
|  |   inputs = { | ||||||
|  |     nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; | ||||||
|  |     flake-utils.url = "github:numtide/flake-utils"; | ||||||
|  |   }; | ||||||
|  |  | ||||||
|  |   outputs = { | ||||||
|  |     self, | ||||||
|  |     nixpkgs, | ||||||
|  |     flake-utils, | ||||||
|  |   }: | ||||||
|  |     flake-utils.lib.eachDefaultSystem (system: let | ||||||
|  |         pkgs = import nixpkgs { | ||||||
|  |           inherit system; | ||||||
|  |         }; | ||||||
|  |       in rec | ||||||
|  |       { | ||||||
|  |         # Nix formatter, run using `$ nix fmt` | ||||||
|  |         formatter = pkgs.alejandra; | ||||||
|  |  | ||||||
|  |         # Exports the tildefriends package | ||||||
|  |         # Build with `$ nix build` | ||||||
|  |         packages.default = pkgs.callPackage ./default.nix {}; | ||||||
|  |  | ||||||
|  |         # Creates a shell with the necessary dependencies | ||||||
|  |         # Enter using `$ nix develop` | ||||||
|  |         devShell = pkgs.mkShell { | ||||||
|  |           buildInputs = with pkgs; [ | ||||||
|  |             openssl | ||||||
|  |             llvmPackages_17.clang-unwrapped | ||||||
|  |             unzip | ||||||
|  |           ]; | ||||||
|  |         }; | ||||||
|  |       }); | ||||||
|  | } | ||||||
							
								
								
									
										23
									
								
								src/ssb.db.c
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								src/ssb.db.c
									
									
									
									
									
								
							| @@ -737,12 +737,11 @@ bool tf_ssb_db_blob_store(tf_ssb_t* ssb, const uint8_t* blob, size_t size, char* | |||||||
| } | } | ||||||
|  |  | ||||||
| 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, char* out_previous, | 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, char* out_previous, | ||||||
| 	size_t out_previous_size, char* out_author, size_t out_author_size, double* out_timestamp, char** out_content, char* out_hash, size_t out_hash_size, char* out_signature, | 	size_t out_previous_size, double* out_timestamp, char** out_content, char* out_hash, size_t out_hash_size, char* out_signature, size_t out_signature_size, int* out_flags) | ||||||
| 	size_t out_signature_size, int* out_flags) |  | ||||||
| { | { | ||||||
| 	bool found = false; | 	bool found = false; | ||||||
| 	sqlite3_stmt* statement; | 	sqlite3_stmt* statement; | ||||||
| 	const char* query = "SELECT id, previous, author, timestamp, json(content), hash, signature, flags FROM messages WHERE author = ?1 AND sequence = ?2"; | 	const char* query = "SELECT id, previous, timestamp, json(content), hash, signature, flags FROM messages WHERE author = ?1 AND sequence = ?2"; | ||||||
| 	sqlite3* db = tf_ssb_acquire_db_reader(ssb); | 	sqlite3* db = tf_ssb_acquire_db_reader(ssb); | ||||||
| 	if (sqlite3_prepare(db, query, -1, &statement, NULL) == SQLITE_OK) | 	if (sqlite3_prepare(db, query, -1, &statement, NULL) == SQLITE_OK) | ||||||
| 	{ | 	{ | ||||||
| @@ -766,29 +765,25 @@ bool tf_ssb_db_get_message_by_author_and_sequence(tf_ssb_t* ssb, const char* aut | |||||||
| 					snprintf(out_previous, out_previous_size, "%s", (const char*)sqlite3_column_text(statement, 1)); | 					snprintf(out_previous, out_previous_size, "%s", (const char*)sqlite3_column_text(statement, 1)); | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 			if (out_author) |  | ||||||
| 			{ |  | ||||||
| 				snprintf(out_author, out_author_size, "%s", (const char*)sqlite3_column_text(statement, 2)); |  | ||||||
| 			} |  | ||||||
| 			if (out_timestamp) | 			if (out_timestamp) | ||||||
| 			{ | 			{ | ||||||
| 				*out_timestamp = sqlite3_column_double(statement, 3); | 				*out_timestamp = sqlite3_column_double(statement, 2); | ||||||
| 			} | 			} | ||||||
| 			if (out_content) | 			if (out_content) | ||||||
| 			{ | 			{ | ||||||
| 				*out_content = tf_strdup((const char*)sqlite3_column_text(statement, 4)); | 				*out_content = tf_strdup((const char*)sqlite3_column_text(statement, 3)); | ||||||
| 			} | 			} | ||||||
| 			if (out_hash) | 			if (out_hash) | ||||||
| 			{ | 			{ | ||||||
| 				snprintf(out_hash, out_hash_size, "%s", (const char*)sqlite3_column_text(statement, 5)); | 				snprintf(out_hash, out_hash_size, "%s", (const char*)sqlite3_column_text(statement, 4)); | ||||||
| 			} | 			} | ||||||
| 			if (out_signature) | 			if (out_signature) | ||||||
| 			{ | 			{ | ||||||
| 				snprintf(out_signature, out_signature_size, "%s", (const char*)sqlite3_column_text(statement, 6)); | 				snprintf(out_signature, out_signature_size, "%s", (const char*)sqlite3_column_text(statement, 5)); | ||||||
| 			} | 			} | ||||||
| 			if (out_flags) | 			if (out_flags) | ||||||
| 			{ | 			{ | ||||||
| 				*out_flags = sqlite3_column_int(statement, 7); | 				*out_flags = sqlite3_column_int(statement, 6); | ||||||
| 			} | 			} | ||||||
| 			found = true; | 			found = true; | ||||||
| 		} | 		} | ||||||
| @@ -1834,8 +1829,8 @@ bool tf_ssb_db_verify(tf_ssb_t* ssb, const char* id) | |||||||
| 			char hash[32]; | 			char hash[32]; | ||||||
| 			char signature[256]; | 			char signature[256]; | ||||||
| 			int flags = 0; | 			int flags = 0; | ||||||
| 			if (tf_ssb_db_get_message_by_author_and_sequence(ssb, id, i, message_id, sizeof(message_id), previous, sizeof(previous), NULL, 0, ×tamp, &content, hash, | 			if (tf_ssb_db_get_message_by_author_and_sequence( | ||||||
| 					sizeof(hash), signature, sizeof(signature), &flags)) | 					ssb, id, i, message_id, sizeof(message_id), previous, sizeof(previous), ×tamp, &content, hash, sizeof(hash), signature, sizeof(signature), &flags)) | ||||||
| 			{ | 			{ | ||||||
| 				JSValue message = tf_ssb_format_message(context, previous, id, i, timestamp, hash, content, signature, flags); | 				JSValue message = tf_ssb_format_message(context, previous, id, i, timestamp, hash, content, signature, flags); | ||||||
| 				char calculated_id[k_id_base64_len]; | 				char calculated_id[k_id_base64_len]; | ||||||
|   | |||||||
							
								
								
									
										16
									
								
								src/ssb.db.h
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								src/ssb.db.h
									
									
									
									
									
								
							| @@ -122,13 +122,19 @@ JSValue tf_ssb_db_get_message_by_id(tf_ssb_t* ssb, const char* id, bool is_keys) | |||||||
| ** @param sequence The message sequence number. | ** @param sequence The message sequence number. | ||||||
| ** @param[out] out_message_id Populated with the message identifier. | ** @param[out] out_message_id Populated with the message identifier. | ||||||
| ** @param out_message_id_size The size of the out_message_id buffer. | ** @param out_message_id_size The size of the out_message_id buffer. | ||||||
|  | ** @param[out] out_previous Populated with the previous message identifier. | ||||||
|  | ** @param out_previous_size The size of the out_previous buffer. | ||||||
| ** @param[out] out_timestamp Populated with the timestamp. | ** @param[out] out_timestamp Populated with the timestamp. | ||||||
| ** @param[out] out_content Populated with the message content.  Free with tf_free(). | ** @param[out] out_content Populated with the message content.  Free with tf_free(). | ||||||
|  | ** @param[out] out_hash Populated with the message hash format. | ||||||
|  | ** @param out_hash_size The size of the out_hash buffer. | ||||||
|  | ** @param[out] out_signature Populated with the message signature. | ||||||
|  | ** @param out_signature_size The size of the out_signature buffer. | ||||||
|  | ** @param[out] out_flags Populated with flags describing the format of the message. | ||||||
| ** @return True if the message was found and retrieved. | ** @return True if the message was found and retrieved. | ||||||
| */ | */ | ||||||
| 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, char* out_previous, | 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, char* out_previous, | ||||||
| 	size_t out_previous_size, char* out_author, size_t out_author_size, double* out_timestamp, char** out_content, char* out_hash, size_t out_hash_size, char* out_signature, | 	size_t out_previous_size, double* out_timestamp, char** out_content, char* out_hash, size_t out_hash_size, char* out_signature, size_t out_signature_size, int* out_flags); | ||||||
| 	size_t out_signature_size, int* out_flags); |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
| ** Get information about the last message from an author. | ** Get information about the last message from an author. | ||||||
| @@ -380,6 +386,12 @@ bool tf_ssb_db_set_property(tf_ssb_t* ssb, const char* id, const char* key, cons | |||||||
| */ | */ | ||||||
| void tf_ssb_db_resolve_index_async(tf_ssb_t* ssb, const char* host, void (*callback)(const char* path, void* user_data), void* user_data); | void tf_ssb_db_resolve_index_async(tf_ssb_t* ssb, const char* host, void (*callback)(const char* path, void* user_data), void* user_data); | ||||||
|  |  | ||||||
|  | /** | ||||||
|  | ** Verify an author's feed. | ||||||
|  | ** @param ssb The SSB instance. | ||||||
|  | ** @param id The author'd identity. | ||||||
|  | ** @return true If the feed verified successfully. | ||||||
|  | */ | ||||||
| bool tf_ssb_db_verify(tf_ssb_t* ssb, const char* id); | bool tf_ssb_db_verify(tf_ssb_t* ssb, const char* id); | ||||||
|  |  | ||||||
| /** | /** | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user