this repo has no description

SQLx query macro the remaining ones

Changed files
+595 -517
.sqlx
src
+15
.sqlx/query-00452ebb198c69e6b83cb5f805007eb92d87b64f1c8c28cf908f695ed82f3408.json
···
··· 1 + { 2 + "db_name": "PostgreSQL", 3 + "query": "INSERT INTO blocks (cid, data) VALUES ($1, $2) ON CONFLICT (cid) DO NOTHING", 4 + "describe": { 5 + "columns": [], 6 + "parameters": { 7 + "Left": [ 8 + "Bytea", 9 + "Bytea" 10 + ] 11 + }, 12 + "nullable": [] 13 + }, 14 + "hash": "00452ebb198c69e6b83cb5f805007eb92d87b64f1c8c28cf908f695ed82f3408" 15 + }
+17
.sqlx/query-1ea62c689410d98faa70a5a6075911a8eeed679b0e3d7bbd103732abc912f45e.json
···
··· 1 + { 2 + "db_name": "PostgreSQL", 3 + "query": "INSERT INTO records (repo_id, collection, rkey, record_cid) VALUES ($1, $2, $3, $4)\n ON CONFLICT (repo_id, collection, rkey) DO UPDATE SET record_cid = $4, created_at = NOW()", 4 + "describe": { 5 + "columns": [], 6 + "parameters": { 7 + "Left": [ 8 + "Uuid", 9 + "Text", 10 + "Text", 11 + "Text" 12 + ] 13 + }, 14 + "nullable": [] 15 + }, 16 + "hash": "1ea62c689410d98faa70a5a6075911a8eeed679b0e3d7bbd103732abc912f45e" 17 + }
+30
.sqlx/query-243ff4911a7d36354e60005af13f6c7d854dc48b8c0d3674f3cbdfd60b61c9d1.json
···
··· 1 + { 2 + "db_name": "PostgreSQL", 3 + "query": "SELECT rkey, record_cid FROM records WHERE repo_id = $1 AND collection = $2 ORDER BY rkey ASC LIMIT $3", 4 + "describe": { 5 + "columns": [ 6 + { 7 + "ordinal": 0, 8 + "name": "rkey", 9 + "type_info": "Text" 10 + }, 11 + { 12 + "ordinal": 1, 13 + "name": "record_cid", 14 + "type_info": "Text" 15 + } 16 + ], 17 + "parameters": { 18 + "Left": [ 19 + "Uuid", 20 + "Text", 21 + "Int8" 22 + ] 23 + }, 24 + "nullable": [ 25 + false, 26 + false 27 + ] 28 + }, 29 + "hash": "243ff4911a7d36354e60005af13f6c7d854dc48b8c0d3674f3cbdfd60b61c9d1" 30 + }
+15
.sqlx/query-2588479ef83ed45a5d0dee599636f195ca38c5df164e225dcb1b829b497c8f14.json
···
··· 1 + { 2 + "db_name": "PostgreSQL", 3 + "query": "UPDATE repos SET repo_root_cid = $1 WHERE user_id = $2", 4 + "describe": { 5 + "columns": [], 6 + "parameters": { 7 + "Left": [ 8 + "Text", 9 + "Uuid" 10 + ] 11 + }, 12 + "nullable": [] 13 + }, 14 + "hash": "2588479ef83ed45a5d0dee599636f195ca38c5df164e225dcb1b829b497c8f14" 15 + }
+30
.sqlx/query-2d37a447ec4dbdb6dfd5ab8c12d1ce88b9be04d6c7b4744891352a9a3bed4f3c.json
···
··· 1 + { 2 + "db_name": "PostgreSQL", 3 + "query": "SELECT rkey, record_cid FROM records WHERE repo_id = $1 AND collection = $2 ORDER BY rkey DESC LIMIT $3", 4 + "describe": { 5 + "columns": [ 6 + { 7 + "ordinal": 0, 8 + "name": "rkey", 9 + "type_info": "Text" 10 + }, 11 + { 12 + "ordinal": 1, 13 + "name": "record_cid", 14 + "type_info": "Text" 15 + } 16 + ], 17 + "parameters": { 18 + "Left": [ 19 + "Uuid", 20 + "Text", 21 + "Int8" 22 + ] 23 + }, 24 + "nullable": [ 25 + false, 26 + false 27 + ] 28 + }, 29 + "hash": "2d37a447ec4dbdb6dfd5ab8c12d1ce88b9be04d6c7b4744891352a9a3bed4f3c" 30 + }
+31
.sqlx/query-347e3570a201ee339904aab43f0519ff631f160c97453e9e8aef04756cbc424e.json
···
··· 1 + { 2 + "db_name": "PostgreSQL", 3 + "query": "SELECT rkey, record_cid FROM records WHERE repo_id = $1 AND collection = $2 AND rkey > $3 ORDER BY rkey ASC LIMIT $4", 4 + "describe": { 5 + "columns": [ 6 + { 7 + "ordinal": 0, 8 + "name": "rkey", 9 + "type_info": "Text" 10 + }, 11 + { 12 + "ordinal": 1, 13 + "name": "record_cid", 14 + "type_info": "Text" 15 + } 16 + ], 17 + "parameters": { 18 + "Left": [ 19 + "Uuid", 20 + "Text", 21 + "Text", 22 + "Int8" 23 + ] 24 + }, 25 + "nullable": [ 26 + false, 27 + false 28 + ] 29 + }, 30 + "hash": "347e3570a201ee339904aab43f0519ff631f160c97453e9e8aef04756cbc424e" 31 + }
+34
.sqlx/query-393066519bf0e1b5b4d2903984001fdd1c17c4cdf8a4af810ce95c05669a04e8.json
···
··· 1 + { 2 + "db_name": "PostgreSQL", 3 + "query": "SELECT id, handle, did FROM users WHERE handle = $1", 4 + "describe": { 5 + "columns": [ 6 + { 7 + "ordinal": 0, 8 + "name": "id", 9 + "type_info": "Uuid" 10 + }, 11 + { 12 + "ordinal": 1, 13 + "name": "handle", 14 + "type_info": "Text" 15 + }, 16 + { 17 + "ordinal": 2, 18 + "name": "did", 19 + "type_info": "Text" 20 + } 21 + ], 22 + "parameters": { 23 + "Left": [ 24 + "Text" 25 + ] 26 + }, 27 + "nullable": [ 28 + false, 29 + false, 30 + false 31 + ] 32 + }, 33 + "hash": "393066519bf0e1b5b4d2903984001fdd1c17c4cdf8a4af810ce95c05669a04e8" 34 + }
+31
.sqlx/query-4343e751b03e24387f6603908a1582d20fdfa58a8e4c17c1628acc6b6f2ded15.json
···
··· 1 + { 2 + "db_name": "PostgreSQL", 3 + "query": "SELECT rkey, record_cid FROM records WHERE repo_id = $1 AND collection = $2 AND rkey < $3 ORDER BY rkey DESC LIMIT $4", 4 + "describe": { 5 + "columns": [ 6 + { 7 + "ordinal": 0, 8 + "name": "rkey", 9 + "type_info": "Text" 10 + }, 11 + { 12 + "ordinal": 1, 13 + "name": "record_cid", 14 + "type_info": "Text" 15 + } 16 + ], 17 + "parameters": { 18 + "Left": [ 19 + "Uuid", 20 + "Text", 21 + "Text", 22 + "Int8" 23 + ] 24 + }, 25 + "nullable": [ 26 + false, 27 + false 28 + ] 29 + }, 30 + "hash": "4343e751b03e24387f6603908a1582d20fdfa58a8e4c17c1628acc6b6f2ded15" 31 + }
+46
.sqlx/query-4bc1e1169d95eac340756b1ba01680caa980514d77cc7b41361c2400f6a5f456.json
···
··· 1 + { 2 + "db_name": "PostgreSQL", 3 + "query": "SELECT r.record_cid, r.rkey, r.created_at, u.did, u.handle\n FROM records r\n JOIN repos rp ON r.repo_id = rp.user_id\n JOIN users u ON rp.user_id = u.id\n WHERE u.did = ANY($1) AND r.collection = 'app.bsky.feed.post'\n ORDER BY r.created_at DESC\n LIMIT 50", 4 + "describe": { 5 + "columns": [ 6 + { 7 + "ordinal": 0, 8 + "name": "record_cid", 9 + "type_info": "Text" 10 + }, 11 + { 12 + "ordinal": 1, 13 + "name": "rkey", 14 + "type_info": "Text" 15 + }, 16 + { 17 + "ordinal": 2, 18 + "name": "created_at", 19 + "type_info": "Timestamptz" 20 + }, 21 + { 22 + "ordinal": 3, 23 + "name": "did", 24 + "type_info": "Text" 25 + }, 26 + { 27 + "ordinal": 4, 28 + "name": "handle", 29 + "type_info": "Text" 30 + } 31 + ], 32 + "parameters": { 33 + "Left": [ 34 + "TextArray" 35 + ] 36 + }, 37 + "nullable": [ 38 + false, 39 + false, 40 + false, 41 + false, 42 + false 43 + ] 44 + }, 45 + "hash": "4bc1e1169d95eac340756b1ba01680caa980514d77cc7b41361c2400f6a5f456" 46 + }
+22
.sqlx/query-63c2b1ecdc078446f8bd898a7c6403c7e64918027933d0a99eae6175bf0ea0ac.json
···
··· 1 + { 2 + "db_name": "PostgreSQL", 3 + "query": "SELECT DISTINCT collection FROM records WHERE repo_id = $1", 4 + "describe": { 5 + "columns": [ 6 + { 7 + "ordinal": 0, 8 + "name": "collection", 9 + "type_info": "Text" 10 + } 11 + ], 12 + "parameters": { 13 + "Left": [ 14 + "Uuid" 15 + ] 16 + }, 17 + "nullable": [ 18 + false 19 + ] 20 + }, 21 + "hash": "63c2b1ecdc078446f8bd898a7c6403c7e64918027933d0a99eae6175bf0ea0ac" 22 + }
+16
.sqlx/query-8c9297289cb753c8eaa4231ae9eab6cd3367f9bf543d9f49bca4afa53434ce0d.json
···
··· 1 + { 2 + "db_name": "PostgreSQL", 3 + "query": "DELETE FROM records WHERE repo_id = $1 AND collection = $2 AND rkey = $3", 4 + "describe": { 5 + "columns": [], 6 + "parameters": { 7 + "Left": [ 8 + "Uuid", 9 + "Text", 10 + "Text" 11 + ] 12 + }, 13 + "nullable": [] 14 + }, 15 + "hash": "8c9297289cb753c8eaa4231ae9eab6cd3367f9bf543d9f49bca4afa53434ce0d" 16 + }
+20
.sqlx/query-bbf600f17712173206b754fd7c8f8f8fd46a03bf54e824ff8046c37a88407123.json
···
··· 1 + { 2 + "db_name": "PostgreSQL", 3 + "query": "SELECT 1 as one", 4 + "describe": { 5 + "columns": [ 6 + { 7 + "ordinal": 0, 8 + "name": "one", 9 + "type_info": "Int4" 10 + } 11 + ], 12 + "parameters": { 13 + "Left": [] 14 + }, 15 + "nullable": [ 16 + null 17 + ] 18 + }, 19 + "hash": "bbf600f17712173206b754fd7c8f8f8fd46a03bf54e824ff8046c37a88407123" 20 + }
+17
.sqlx/query-c61fc3b2fbdf6891269908ef21f13dcabdc3b032e9f767becae34ca176df18b6.json
···
··· 1 + { 2 + "db_name": "PostgreSQL", 3 + "query": "INSERT INTO records (repo_id, collection, rkey, record_cid) VALUES ($1, $2, $3, $4)\n ON CONFLICT (repo_id, collection, rkey) DO UPDATE SET record_cid = $4, created_at = NOW()", 4 + "describe": { 5 + "columns": [], 6 + "parameters": { 7 + "Left": [ 8 + "Uuid", 9 + "Text", 10 + "Text", 11 + "Text" 12 + ] 13 + }, 14 + "nullable": [] 15 + }, 16 + "hash": "c61fc3b2fbdf6891269908ef21f13dcabdc3b032e9f767becae34ca176df18b6" 17 + }
+22
.sqlx/query-ce7977cb9183b587a2c2a56b4e5d52a6de786b5d3a05af4c2245fd61b98d0168.json
···
··· 1 + { 2 + "db_name": "PostgreSQL", 3 + "query": "SELECT id FROM users WHERE handle = $1", 4 + "describe": { 5 + "columns": [ 6 + { 7 + "ordinal": 0, 8 + "name": "id", 9 + "type_info": "Uuid" 10 + } 11 + ], 12 + "parameters": { 13 + "Left": [ 14 + "Text" 15 + ] 16 + }, 17 + "nullable": [ 18 + false 19 + ] 20 + }, 21 + "hash": "ce7977cb9183b587a2c2a56b4e5d52a6de786b5d3a05af4c2245fd61b98d0168" 22 + }
+22
.sqlx/query-ebceb64378f0e06c61c72d10f65fb7df83e09e82153d92dee4efef62de057505.json
···
··· 1 + { 2 + "db_name": "PostgreSQL", 3 + "query": "SELECT data FROM blocks WHERE cid = $1", 4 + "describe": { 5 + "columns": [ 6 + { 7 + "ordinal": 0, 8 + "name": "data", 9 + "type_info": "Bytea" 10 + } 11 + ], 12 + "parameters": { 13 + "Left": [ 14 + "Bytea" 15 + ] 16 + }, 17 + "nullable": [ 18 + false 19 + ] 20 + }, 21 + "hash": "ebceb64378f0e06c61c72d10f65fb7df83e09e82153d92dee4efef62de057505" 22 + }
+24
.sqlx/query-f09c0e92f101ef5abe2579083a26f782946646a8bd813bcd6cc568a6b7fc8f6d.json
···
··· 1 + { 2 + "db_name": "PostgreSQL", 3 + "query": "SELECT record_cid FROM records WHERE repo_id = $1 AND collection = $2 AND rkey = $3", 4 + "describe": { 5 + "columns": [ 6 + { 7 + "ordinal": 0, 8 + "name": "record_cid", 9 + "type_info": "Text" 10 + } 11 + ], 12 + "parameters": { 13 + "Left": [ 14 + "Uuid", 15 + "Text", 16 + "Text" 17 + ] 18 + }, 19 + "nullable": [ 20 + false 21 + ] 22 + }, 23 + "hash": "f09c0e92f101ef5abe2579083a26f782946646a8bd813bcd6cc568a6b7fc8f6d" 24 + }
+22
.sqlx/query-fba80b51dd803209fd2691b07213b68eade7427381a61268d16cb4cac357ac69.json
···
··· 1 + { 2 + "db_name": "PostgreSQL", 3 + "query": "SELECT 1 as one FROM blocks WHERE cid = $1", 4 + "describe": { 5 + "columns": [ 6 + { 7 + "ordinal": 0, 8 + "name": "one", 9 + "type_info": "Int4" 10 + } 11 + ], 12 + "parameters": { 13 + "Left": [ 14 + "Bytea" 15 + ] 16 + }, 17 + "nullable": [ 18 + null 19 + ] 20 + }, 21 + "hash": "fba80b51dd803209fd2691b07213b68eade7427381a61268d16cb4cac357ac69" 22 + }
+34
.sqlx/query-fd1efe850ae4d8b9d834aba414a5b97f20094c790804c60079905b199e9d3858.json
···
··· 1 + { 2 + "db_name": "PostgreSQL", 3 + "query": "SELECT id, handle, did FROM users WHERE did = $1", 4 + "describe": { 5 + "columns": [ 6 + { 7 + "ordinal": 0, 8 + "name": "id", 9 + "type_info": "Uuid" 10 + }, 11 + { 12 + "ordinal": 1, 13 + "name": "handle", 14 + "type_info": "Text" 15 + }, 16 + { 17 + "ordinal": 2, 18 + "name": "did", 19 + "type_info": "Text" 20 + } 21 + ], 22 + "parameters": { 23 + "Left": [ 24 + "Text" 25 + ] 26 + }, 27 + "nullable": [ 28 + false, 29 + false, 30 + false 31 + ] 32 + }, 33 + "hash": "fd1efe850ae4d8b9d834aba414a5b97f20094c790804c60079905b199e9d3858" 34 + }
-353
Cargo.lock
··· 28 checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" 29 30 [[package]] 31 - name = "adler32" 32 - version = "1.2.0" 33 - source = "registry+https://github.com/rust-lang/crates.io-index" 34 - checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" 35 - 36 - [[package]] 37 name = "aho-corasick" 38 version = "1.1.4" 39 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 49 checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" 50 51 [[package]] 52 - name = "alloc-no-stdlib" 53 - version = "2.0.4" 54 - source = "registry+https://github.com/rust-lang/crates.io-index" 55 - checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" 56 - 57 - [[package]] 58 - name = "alloc-stdlib" 59 - version = "0.2.2" 60 - source = "registry+https://github.com/rust-lang/crates.io-index" 61 - checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" 62 - dependencies = [ 63 - "alloc-no-stdlib", 64 - ] 65 - 66 - [[package]] 67 name = "allocator-api2" 68 version = "0.2.21" 69 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 83 version = "1.0.100" 84 source = "registry+https://github.com/rust-lang/crates.io-index" 85 checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" 86 - 87 - [[package]] 88 - name = "ascii" 89 - version = "1.1.0" 90 - source = "registry+https://github.com/rust-lang/crates.io-index" 91 - checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" 92 93 [[package]] 94 name = "assert-json-diff" ··· 695 696 [[package]] 697 name = "base64" 698 - version = "0.13.1" 699 - source = "registry+https://github.com/rust-lang/crates.io-index" 700 - checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" 701 - 702 - [[package]] 703 - name = "base64" 704 version = "0.21.7" 705 source = "registry+https://github.com/rust-lang/crates.io-index" 706 checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" ··· 880 ] 881 882 [[package]] 883 - name = "brotli" 884 - version = "3.5.0" 885 - source = "registry+https://github.com/rust-lang/crates.io-index" 886 - checksum = "d640d25bc63c50fb1f0b545ffd80207d2e10a4c965530809b40ba3386825c391" 887 - dependencies = [ 888 - "alloc-no-stdlib", 889 - "alloc-stdlib", 890 - "brotli-decompressor", 891 - ] 892 - 893 - [[package]] 894 - name = "brotli-decompressor" 895 - version = "2.5.1" 896 - source = "registry+https://github.com/rust-lang/crates.io-index" 897 - checksum = "4e2e4afe60d7dd600fdd3de8d0f08c2b7ec039712e3b6137ff98b7004e82de4f" 898 - dependencies = [ 899 - "alloc-no-stdlib", 900 - "alloc-stdlib", 901 - ] 902 - 903 - [[package]] 904 name = "bspds" 905 version = "0.1.0" 906 dependencies = [ ··· 962 "cc-traits", 963 "slab", 964 "smallvec", 965 - ] 966 - 967 - [[package]] 968 - name = "buf_redux" 969 - version = "0.8.4" 970 - source = "registry+https://github.com/rust-lang/crates.io-index" 971 - checksum = "b953a6887648bb07a535631f2bc00fbdb2a2216f135552cb3f534ed136b9c07f" 972 - dependencies = [ 973 - "memchr", 974 - "safemem", 975 ] 976 977 [[package]] ··· 1073 ] 1074 1075 [[package]] 1076 - name = "cesu8" 1077 - version = "1.1.0" 1078 - source = "registry+https://github.com/rust-lang/crates.io-index" 1079 - checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" 1080 - 1081 - [[package]] 1082 name = "cfg-if" 1083 version = "1.0.4" 1084 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1103 "wasm-bindgen", 1104 "windows-link 0.2.1", 1105 ] 1106 - 1107 - [[package]] 1108 - name = "chunked_transfer" 1109 - version = "1.5.0" 1110 - source = "registry+https://github.com/rust-lang/crates.io-index" 1111 - checksum = "6e4de3bc4ea267985becf712dc6d9eed8b04c953b3fcfb339ebc87acd9804901" 1112 1113 [[package]] 1114 name = "ciborium" ··· 1168 checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" 1169 dependencies = [ 1170 "cc", 1171 - ] 1172 - 1173 - [[package]] 1174 - name = "combine" 1175 - version = "4.6.7" 1176 - source = "registry+https://github.com/rust-lang/crates.io-index" 1177 - checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" 1178 - dependencies = [ 1179 - "bytes", 1180 - "memchr", 1181 ] 1182 1183 [[package]] ··· 1523 checksum = "092966b41edc516079bdf31ec78a2e0588d1d0c08f78b91d8307215928642b2b" 1524 1525 [[package]] 1526 - name = "deflate" 1527 - version = "1.0.0" 1528 - source = "registry+https://github.com/rust-lang/crates.io-index" 1529 - checksum = "c86f7e25f518f4b81808a2cf1c50996a61f5c2eb394b2393bd87f2a4780a432f" 1530 - dependencies = [ 1531 - "adler32", 1532 - "gzip-header", 1533 - ] 1534 - 1535 - [[package]] 1536 name = "der" 1537 version = "0.6.1" 1538 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2202 "ff 0.13.1", 2203 "rand_core 0.6.4", 2204 "subtle", 2205 - ] 2206 - 2207 - [[package]] 2208 - name = "gzip-header" 2209 - version = "1.0.0" 2210 - source = "registry+https://github.com/rust-lang/crates.io-index" 2211 - checksum = "95cc527b92e6029a62960ad99aa8a6660faa4555fe5f731aab13aa6a921795a2" 2212 - dependencies = [ 2213 - "crc32fast", 2214 ] 2215 2216 [[package]] ··· 3100 "miette", 3101 "p256 0.13.2", 3102 "rand 0.8.5", 3103 - "rouille", 3104 "serde", 3105 "serde_html_form", 3106 "serde_json", ··· 3110 "tokio", 3111 "trait-variant", 3112 "url", 3113 - "webbrowser", 3114 ] 3115 3116 [[package]] ··· 3141 ] 3142 3143 [[package]] 3144 - name = "jni" 3145 - version = "0.21.1" 3146 - source = "registry+https://github.com/rust-lang/crates.io-index" 3147 - checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" 3148 - dependencies = [ 3149 - "cesu8", 3150 - "cfg-if", 3151 - "combine", 3152 - "jni-sys", 3153 - "log", 3154 - "thiserror 1.0.69", 3155 - "walkdir", 3156 - "windows-sys 0.45.0", 3157 - ] 3158 - 3159 - [[package]] 3160 - name = "jni-sys" 3161 - version = "0.3.0" 3162 - source = "registry+https://github.com/rust-lang/crates.io-index" 3163 - checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" 3164 - 3165 - [[package]] 3166 name = "jobserver" 3167 version = "0.1.34" 3168 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3481 checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" 3482 3483 [[package]] 3484 - name = "mime_guess" 3485 - version = "2.0.5" 3486 - source = "registry+https://github.com/rust-lang/crates.io-index" 3487 - checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" 3488 - dependencies = [ 3489 - "mime", 3490 - "unicase", 3491 - ] 3492 - 3493 - [[package]] 3494 name = "mini-moka" 3495 version = "0.10.3" 3496 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3556 ] 3557 3558 [[package]] 3559 - name = "multipart" 3560 - version = "0.18.0" 3561 - source = "registry+https://github.com/rust-lang/crates.io-index" 3562 - checksum = "00dec633863867f29cb39df64a397cdf4a6354708ddd7759f70c7fb51c5f9182" 3563 - dependencies = [ 3564 - "buf_redux", 3565 - "httparse", 3566 - "log", 3567 - "mime", 3568 - "mime_guess", 3569 - "quick-error", 3570 - "rand 0.8.5", 3571 - "safemem", 3572 - "tempfile", 3573 - "twoway", 3574 - ] 3575 - 3576 - [[package]] 3577 name = "n0-future" 3578 version = "0.1.3" 3579 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3610 "security-framework-sys", 3611 "tempfile", 3612 ] 3613 - 3614 - [[package]] 3615 - name = "ndk-context" 3616 - version = "0.1.1" 3617 - source = "registry+https://github.com/rust-lang/crates.io-index" 3618 - checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" 3619 3620 [[package]] 3621 name = "new_debug_unreachable" ··· 3749 ] 3750 3751 [[package]] 3752 - name = "num_threads" 3753 - version = "0.1.7" 3754 - source = "registry+https://github.com/rust-lang/crates.io-index" 3755 - checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" 3756 - dependencies = [ 3757 - "libc", 3758 - ] 3759 - 3760 - [[package]] 3761 - name = "objc2" 3762 - version = "0.6.3" 3763 - source = "registry+https://github.com/rust-lang/crates.io-index" 3764 - checksum = "b7c2599ce0ec54857b29ce62166b0ed9b4f6f1a70ccc9a71165b6154caca8c05" 3765 - dependencies = [ 3766 - "objc2-encode", 3767 - ] 3768 - 3769 - [[package]] 3770 - name = "objc2-encode" 3771 - version = "4.1.0" 3772 - source = "registry+https://github.com/rust-lang/crates.io-index" 3773 - checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" 3774 - 3775 - [[package]] 3776 - name = "objc2-foundation" 3777 - version = "0.3.2" 3778 - source = "registry+https://github.com/rust-lang/crates.io-index" 3779 - checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" 3780 - dependencies = [ 3781 - "bitflags", 3782 - "objc2", 3783 - ] 3784 - 3785 - [[package]] 3786 name = "once_cell" 3787 version = "1.21.3" 3788 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 4228 ] 4229 4230 [[package]] 4231 - name = "quick-error" 4232 - version = "1.2.3" 4233 - source = "registry+https://github.com/rust-lang/crates.io-index" 4234 - checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" 4235 - 4236 - [[package]] 4237 name = "quinn" 4238 version = "0.11.9" 4239 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 4522 ] 4523 4524 [[package]] 4525 - name = "rouille" 4526 - version = "3.6.2" 4527 - source = "registry+https://github.com/rust-lang/crates.io-index" 4528 - checksum = "3716fbf57fc1084d7a706adf4e445298d123e4a44294c4e8213caf1b85fcc921" 4529 - dependencies = [ 4530 - "base64 0.13.1", 4531 - "brotli", 4532 - "chrono", 4533 - "deflate", 4534 - "filetime", 4535 - "multipart", 4536 - "percent-encoding", 4537 - "rand 0.8.5", 4538 - "serde", 4539 - "serde_derive", 4540 - "serde_json", 4541 - "sha1_smol", 4542 - "threadpool", 4543 - "time", 4544 - "tiny_http", 4545 - "url", 4546 - ] 4547 - 4548 - [[package]] 4549 name = "rsa" 4550 version = "0.9.9" 4551 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 4706 version = "1.0.20" 4707 source = "registry+https://github.com/rust-lang/crates.io-index" 4708 checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" 4709 - 4710 - [[package]] 4711 - name = "safemem" 4712 - version = "0.3.3" 4713 - source = "registry+https://github.com/rust-lang/crates.io-index" 4714 - checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" 4715 4716 [[package]] 4717 name = "same-file" ··· 5010 "cpufeatures", 5011 "digest", 5012 ] 5013 - 5014 - [[package]] 5015 - name = "sha1_smol" 5016 - version = "1.0.1" 5017 - source = "registry+https://github.com/rust-lang/crates.io-index" 5018 - checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d" 5019 5020 [[package]] 5021 name = "sha2" ··· 5674 ] 5675 5676 [[package]] 5677 - name = "threadpool" 5678 - version = "1.8.1" 5679 - source = "registry+https://github.com/rust-lang/crates.io-index" 5680 - checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" 5681 - dependencies = [ 5682 - "num_cpus", 5683 - ] 5684 - 5685 - [[package]] 5686 name = "time" 5687 version = "0.3.44" 5688 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 5690 dependencies = [ 5691 "deranged", 5692 "itoa", 5693 - "libc", 5694 "num-conv", 5695 - "num_threads", 5696 "powerfmt", 5697 "serde", 5698 "time-core", ··· 5713 dependencies = [ 5714 "num-conv", 5715 "time-core", 5716 - ] 5717 - 5718 - [[package]] 5719 - name = "tiny_http" 5720 - version = "0.12.0" 5721 - source = "registry+https://github.com/rust-lang/crates.io-index" 5722 - checksum = "389915df6413a2e74fb181895f933386023c71110878cd0825588928e64cdc82" 5723 - dependencies = [ 5724 - "ascii", 5725 - "chunked_transfer", 5726 - "httpdate", 5727 - "log", 5728 ] 5729 5730 [[package]] ··· 6010 checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" 6011 6012 [[package]] 6013 - name = "twoway" 6014 - version = "0.1.8" 6015 - source = "registry+https://github.com/rust-lang/crates.io-index" 6016 - checksum = "59b11b2b5241ba34be09c3cc85a36e56e48f9888862e19cedf23336d35316ed1" 6017 - dependencies = [ 6018 - "memchr", 6019 - ] 6020 - 6021 - [[package]] 6022 name = "typenum" 6023 version = "1.19.0" 6024 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 6316 dependencies = [ 6317 "js-sys", 6318 "wasm-bindgen", 6319 - ] 6320 - 6321 - [[package]] 6322 - name = "webbrowser" 6323 - version = "1.0.6" 6324 - source = "registry+https://github.com/rust-lang/crates.io-index" 6325 - checksum = "00f1243ef785213e3a32fa0396093424a3a6ea566f9948497e5a2309261a4c97" 6326 - dependencies = [ 6327 - "core-foundation 0.10.1", 6328 - "jni", 6329 - "log", 6330 - "ndk-context", 6331 - "objc2", 6332 - "objc2-foundation", 6333 - "url", 6334 - "web-sys", 6335 ] 6336 6337 [[package]] ··· 6563 6564 [[package]] 6565 name = "windows-sys" 6566 - version = "0.45.0" 6567 - source = "registry+https://github.com/rust-lang/crates.io-index" 6568 - checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" 6569 - dependencies = [ 6570 - "windows-targets 0.42.2", 6571 - ] 6572 - 6573 - [[package]] 6574 - name = "windows-sys" 6575 version = "0.48.0" 6576 source = "registry+https://github.com/rust-lang/crates.io-index" 6577 checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" ··· 6608 6609 [[package]] 6610 name = "windows-targets" 6611 - version = "0.42.2" 6612 - source = "registry+https://github.com/rust-lang/crates.io-index" 6613 - checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" 6614 - dependencies = [ 6615 - "windows_aarch64_gnullvm 0.42.2", 6616 - "windows_aarch64_msvc 0.42.2", 6617 - "windows_i686_gnu 0.42.2", 6618 - "windows_i686_msvc 0.42.2", 6619 - "windows_x86_64_gnu 0.42.2", 6620 - "windows_x86_64_gnullvm 0.42.2", 6621 - "windows_x86_64_msvc 0.42.2", 6622 - ] 6623 - 6624 - [[package]] 6625 - name = "windows-targets" 6626 version = "0.48.5" 6627 source = "registry+https://github.com/rust-lang/crates.io-index" 6628 checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" ··· 6680 6681 [[package]] 6682 name = "windows_aarch64_gnullvm" 6683 - version = "0.42.2" 6684 - source = "registry+https://github.com/rust-lang/crates.io-index" 6685 - checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" 6686 - 6687 - [[package]] 6688 - name = "windows_aarch64_gnullvm" 6689 version = "0.48.5" 6690 source = "registry+https://github.com/rust-lang/crates.io-index" 6691 checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" ··· 6704 6705 [[package]] 6706 name = "windows_aarch64_msvc" 6707 - version = "0.42.2" 6708 - source = "registry+https://github.com/rust-lang/crates.io-index" 6709 - checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" 6710 - 6711 - [[package]] 6712 - name = "windows_aarch64_msvc" 6713 version = "0.48.5" 6714 source = "registry+https://github.com/rust-lang/crates.io-index" 6715 checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" ··· 6725 version = "0.53.1" 6726 source = "registry+https://github.com/rust-lang/crates.io-index" 6727 checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" 6728 - 6729 - [[package]] 6730 - name = "windows_i686_gnu" 6731 - version = "0.42.2" 6732 - source = "registry+https://github.com/rust-lang/crates.io-index" 6733 - checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" 6734 6735 [[package]] 6736 name = "windows_i686_gnu" ··· 6764 6765 [[package]] 6766 name = "windows_i686_msvc" 6767 - version = "0.42.2" 6768 - source = "registry+https://github.com/rust-lang/crates.io-index" 6769 - checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" 6770 - 6771 - [[package]] 6772 - name = "windows_i686_msvc" 6773 version = "0.48.5" 6774 source = "registry+https://github.com/rust-lang/crates.io-index" 6775 checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" ··· 6788 6789 [[package]] 6790 name = "windows_x86_64_gnu" 6791 - version = "0.42.2" 6792 - source = "registry+https://github.com/rust-lang/crates.io-index" 6793 - checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" 6794 - 6795 - [[package]] 6796 - name = "windows_x86_64_gnu" 6797 version = "0.48.5" 6798 source = "registry+https://github.com/rust-lang/crates.io-index" 6799 checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" ··· 6812 6813 [[package]] 6814 name = "windows_x86_64_gnullvm" 6815 - version = "0.42.2" 6816 - source = "registry+https://github.com/rust-lang/crates.io-index" 6817 - checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" 6818 - 6819 - [[package]] 6820 - name = "windows_x86_64_gnullvm" 6821 version = "0.48.5" 6822 source = "registry+https://github.com/rust-lang/crates.io-index" 6823 checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" ··· 6833 version = "0.53.1" 6834 source = "registry+https://github.com/rust-lang/crates.io-index" 6835 checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" 6836 - 6837 - [[package]] 6838 - name = "windows_x86_64_msvc" 6839 - version = "0.42.2" 6840 - source = "registry+https://github.com/rust-lang/crates.io-index" 6841 - checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" 6842 6843 [[package]] 6844 name = "windows_x86_64_msvc"
··· 28 checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" 29 30 [[package]] 31 name = "aho-corasick" 32 version = "1.1.4" 33 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 43 checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" 44 45 [[package]] 46 name = "allocator-api2" 47 version = "0.2.21" 48 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 62 version = "1.0.100" 63 source = "registry+https://github.com/rust-lang/crates.io-index" 64 checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" 65 66 [[package]] 67 name = "assert-json-diff" ··· 668 669 [[package]] 670 name = "base64" 671 version = "0.21.7" 672 source = "registry+https://github.com/rust-lang/crates.io-index" 673 checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" ··· 847 ] 848 849 [[package]] 850 name = "bspds" 851 version = "0.1.0" 852 dependencies = [ ··· 908 "cc-traits", 909 "slab", 910 "smallvec", 911 ] 912 913 [[package]] ··· 1009 ] 1010 1011 [[package]] 1012 name = "cfg-if" 1013 version = "1.0.4" 1014 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1033 "wasm-bindgen", 1034 "windows-link 0.2.1", 1035 ] 1036 1037 [[package]] 1038 name = "ciborium" ··· 1092 checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" 1093 dependencies = [ 1094 "cc", 1095 ] 1096 1097 [[package]] ··· 1437 checksum = "092966b41edc516079bdf31ec78a2e0588d1d0c08f78b91d8307215928642b2b" 1438 1439 [[package]] 1440 name = "der" 1441 version = "0.6.1" 1442 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2106 "ff 0.13.1", 2107 "rand_core 0.6.4", 2108 "subtle", 2109 ] 2110 2111 [[package]] ··· 2995 "miette", 2996 "p256 0.13.2", 2997 "rand 0.8.5", 2998 "serde", 2999 "serde_html_form", 3000 "serde_json", ··· 3004 "tokio", 3005 "trait-variant", 3006 "url", 3007 ] 3008 3009 [[package]] ··· 3034 ] 3035 3036 [[package]] 3037 name = "jobserver" 3038 version = "0.1.34" 3039 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3352 checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" 3353 3354 [[package]] 3355 name = "mini-moka" 3356 version = "0.10.3" 3357 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3417 ] 3418 3419 [[package]] 3420 name = "n0-future" 3421 version = "0.1.3" 3422 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3453 "security-framework-sys", 3454 "tempfile", 3455 ] 3456 3457 [[package]] 3458 name = "new_debug_unreachable" ··· 3586 ] 3587 3588 [[package]] 3589 name = "once_cell" 3590 version = "1.21.3" 3591 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 4031 ] 4032 4033 [[package]] 4034 name = "quinn" 4035 version = "0.11.9" 4036 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 4319 ] 4320 4321 [[package]] 4322 name = "rsa" 4323 version = "0.9.9" 4324 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 4479 version = "1.0.20" 4480 source = "registry+https://github.com/rust-lang/crates.io-index" 4481 checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" 4482 4483 [[package]] 4484 name = "same-file" ··· 4777 "cpufeatures", 4778 "digest", 4779 ] 4780 4781 [[package]] 4782 name = "sha2" ··· 5435 ] 5436 5437 [[package]] 5438 name = "time" 5439 version = "0.3.44" 5440 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 5442 dependencies = [ 5443 "deranged", 5444 "itoa", 5445 "num-conv", 5446 "powerfmt", 5447 "serde", 5448 "time-core", ··· 5463 dependencies = [ 5464 "num-conv", 5465 "time-core", 5466 ] 5467 5468 [[package]] ··· 5748 checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" 5749 5750 [[package]] 5751 name = "typenum" 5752 version = "1.19.0" 5753 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 6045 dependencies = [ 6046 "js-sys", 6047 "wasm-bindgen", 6048 ] 6049 6050 [[package]] ··· 6276 6277 [[package]] 6278 name = "windows-sys" 6279 version = "0.48.0" 6280 source = "registry+https://github.com/rust-lang/crates.io-index" 6281 checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" ··· 6312 6313 [[package]] 6314 name = "windows-targets" 6315 version = "0.48.5" 6316 source = "registry+https://github.com/rust-lang/crates.io-index" 6317 checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" ··· 6369 6370 [[package]] 6371 name = "windows_aarch64_gnullvm" 6372 version = "0.48.5" 6373 source = "registry+https://github.com/rust-lang/crates.io-index" 6374 checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" ··· 6387 6388 [[package]] 6389 name = "windows_aarch64_msvc" 6390 version = "0.48.5" 6391 source = "registry+https://github.com/rust-lang/crates.io-index" 6392 checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" ··· 6402 version = "0.53.1" 6403 source = "registry+https://github.com/rust-lang/crates.io-index" 6404 checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" 6405 6406 [[package]] 6407 name = "windows_i686_gnu" ··· 6435 6436 [[package]] 6437 name = "windows_i686_msvc" 6438 version = "0.48.5" 6439 source = "registry+https://github.com/rust-lang/crates.io-index" 6440 checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" ··· 6453 6454 [[package]] 6455 name = "windows_x86_64_gnu" 6456 version = "0.48.5" 6457 source = "registry+https://github.com/rust-lang/crates.io-index" 6458 checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" ··· 6471 6472 [[package]] 6473 name = "windows_x86_64_gnullvm" 6474 version = "0.48.5" 6475 source = "registry+https://github.com/rust-lang/crates.io-index" 6476 checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" ··· 6486 version = "0.53.1" 6487 source = "registry+https://github.com/rust-lang/crates.io-index" 6488 checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" 6489 6490 [[package]] 6491 name = "windows_x86_64_msvc"
+1 -1
Cargo.toml
··· 15 chrono = { version = "0.4.42", features = ["serde"] } 16 cid = "0.11.1" 17 dotenvy = "0.15.7" 18 - jacquard = "0.9.3" 19 jacquard-axum = "0.9.2" 20 jacquard-repo = "0.9.2" 21 jsonwebtoken = { version = "10.2.0", features = ["rust_crypto"] }
··· 15 chrono = { version = "0.4.42", features = ["serde"] } 16 cid = "0.11.1" 17 dotenvy = "0.15.7" 18 + jacquard = { version = "0.9.3", default-features = false, features = ["api", "api_bluesky", "api_full", "derive", "dns"] } 19 jacquard-axum = "0.9.2" 20 jacquard-repo = "0.9.2" 21 jsonwebtoken = { version = "10.2.0", features = ["rust_crypto"] }
+11 -23
src/api/feed/timeline.rs
··· 11 use jacquard_repo::storage::BlockStore; 12 use serde::Serialize; 13 use serde_json::{Value, json}; 14 - use sqlx::Row; 15 use tracing::error; 16 17 #[derive(Serialize)] ··· 153 .into_response(); 154 } 155 156 - let placeholders: Vec<String> = followed_dids 157 - .iter() 158 - .enumerate() 159 - .map(|(i, _)| format!("${}", i + 1)) 160 - .collect(); 161 - 162 - let posts_query = format!( 163 "SELECT r.record_cid, r.rkey, r.created_at, u.did, u.handle 164 FROM records r 165 JOIN repos rp ON r.repo_id = rp.user_id 166 JOIN users u ON rp.user_id = u.id 167 - WHERE u.did IN ({}) AND r.collection = 'app.bsky.feed.post' 168 ORDER BY r.created_at DESC 169 LIMIT 50", 170 - placeholders.join(", ") 171 - ); 172 - 173 - let mut query = sqlx::query(&posts_query); 174 - for did in &followed_dids { 175 - query = query.bind(did); 176 - } 177 - 178 - let posts_result = query.fetch_all(&state.db).await; 179 180 let posts = match posts_result { 181 Ok(rows) => rows, ··· 192 let mut feed: Vec<FeedViewPost> = Vec::new(); 193 194 for row in posts { 195 - let record_cid: String = row.get("record_cid"); 196 - let rkey: String = row.get("rkey"); 197 - let created_at: chrono::DateTime<chrono::Utc> = row.get("created_at"); 198 - let author_did: String = row.get("did"); 199 - let author_handle: String = row.get("handle"); 200 201 let cid = match record_cid.parse::<cid::Cid>() { 202 Ok(c) => c,
··· 11 use jacquard_repo::storage::BlockStore; 12 use serde::Serialize; 13 use serde_json::{Value, json}; 14 use tracing::error; 15 16 #[derive(Serialize)] ··· 152 .into_response(); 153 } 154 155 + let posts_result = sqlx::query!( 156 "SELECT r.record_cid, r.rkey, r.created_at, u.did, u.handle 157 FROM records r 158 JOIN repos rp ON r.repo_id = rp.user_id 159 JOIN users u ON rp.user_id = u.id 160 + WHERE u.did = ANY($1) AND r.collection = 'app.bsky.feed.post' 161 ORDER BY r.created_at DESC 162 LIMIT 50", 163 + &followed_dids 164 + ) 165 + .fetch_all(&state.db) 166 + .await; 167 168 let posts = match posts_result { 169 Ok(rows) => rows, ··· 180 let mut feed: Vec<FeedViewPost> = Vec::new(); 181 182 for row in posts { 183 + let record_cid: String = row.record_cid; 184 + let rkey: String = row.rkey; 185 + let created_at: chrono::DateTime<chrono::Utc> = row.created_at; 186 + let author_did: String = row.did; 187 + let author_handle: String = row.handle; 188 189 let cid = match record_cid.parse::<cid::Cid>() { 190 Ok(c) => c,
+7 -13
src/api/repo/meta.rs
··· 7 }; 8 use serde::Deserialize; 9 use serde_json::json; 10 - use sqlx::Row; 11 12 #[derive(Deserialize)] 13 pub struct DescribeRepoInput { ··· 19 Query(input): Query<DescribeRepoInput>, 20 ) -> Response { 21 let user_row = if input.repo.starts_with("did:") { 22 - sqlx::query("SELECT id, handle, did FROM users WHERE did = $1") 23 - .bind(&input.repo) 24 .fetch_optional(&state.db) 25 .await 26 } else { 27 - sqlx::query("SELECT id, handle, did FROM users WHERE handle = $1") 28 - .bind(&input.repo) 29 .fetch_optional(&state.db) 30 .await 31 }; 32 33 let (user_id, handle, did) = match user_row { 34 - Ok(Some(row)) => ( 35 - row.get::<uuid::Uuid, _>("id"), 36 - row.get::<String, _>("handle"), 37 - row.get::<String, _>("did"), 38 - ), 39 _ => { 40 return ( 41 StatusCode::NOT_FOUND, ··· 46 }; 47 48 let collections_query = 49 - sqlx::query("SELECT DISTINCT collection FROM records WHERE repo_id = $1") 50 - .bind(user_id) 51 .fetch_all(&state.db) 52 .await; 53 54 let collections: Vec<String> = match collections_query { 55 - Ok(rows) => rows.iter().map(|r| r.get("collection")).collect(), 56 Err(_) => Vec::new(), 57 }; 58
··· 7 }; 8 use serde::Deserialize; 9 use serde_json::json; 10 11 #[derive(Deserialize)] 12 pub struct DescribeRepoInput { ··· 18 Query(input): Query<DescribeRepoInput>, 19 ) -> Response { 20 let user_row = if input.repo.starts_with("did:") { 21 + sqlx::query!("SELECT id, handle, did FROM users WHERE did = $1", input.repo) 22 .fetch_optional(&state.db) 23 .await 24 + .map(|opt| opt.map(|r| (r.id, r.handle, r.did))) 25 } else { 26 + sqlx::query!("SELECT id, handle, did FROM users WHERE handle = $1", input.repo) 27 .fetch_optional(&state.db) 28 .await 29 + .map(|opt| opt.map(|r| (r.id, r.handle, r.did))) 30 }; 31 32 let (user_id, handle, did) = match user_row { 33 + Ok(Some((id, handle, did))) => (id, handle, did), 34 _ => { 35 return ( 36 StatusCode::NOT_FOUND, ··· 41 }; 42 43 let collections_query = 44 + sqlx::query!("SELECT DISTINCT collection FROM records WHERE repo_id = $1", user_id) 45 .fetch_all(&state.db) 46 .await; 47 48 let collections: Vec<String> = match collections_query { 49 + Ok(rows) => rows.iter().map(|r| r.collection.clone()).collect(), 50 Err(_) => Vec::new(), 51 }; 52
+19 -24
src/api/repo/record/batch.rs
··· 15 use jacquard_repo::{commit::Commit, mst::Mst, storage::BlockStore}; 16 use serde::{Deserialize, Serialize}; 17 use serde_json::json; 18 - use sqlx::Row; 19 use std::str::FromStr; 20 use std::sync::Arc; 21 use tracing::error; ··· 90 .unwrap_or("") 91 .replace("Bearer ", ""); 92 93 - let session = sqlx::query( 94 - "SELECT s.did, k.key_bytes FROM sessions s JOIN users u ON s.did = u.did JOIN user_keys k ON u.id = k.user_id WHERE s.access_jwt = $1" 95 ) 96 - .bind(&token) 97 .fetch_optional(&state.db) 98 .await 99 .unwrap_or(None); 100 101 let (did, key_bytes) = match session { 102 Some(row) => ( 103 - row.get::<String, _>("did"), 104 - row.get::<Vec<u8>, _>("key_bytes"), 105 ), 106 None => { 107 return ( ··· 144 .into_response(); 145 } 146 147 - let user_query = sqlx::query("SELECT id FROM users WHERE did = $1") 148 - .bind(&did) 149 .fetch_optional(&state.db) 150 .await; 151 152 let user_id: uuid::Uuid = match user_query { 153 - Ok(Some(row)) => row.get("id"), 154 _ => { 155 return ( 156 StatusCode::INTERNAL_SERVER_ERROR, ··· 160 } 161 }; 162 163 - let repo_root_query = sqlx::query("SELECT repo_root_cid FROM repos WHERE user_id = $1") 164 - .bind(user_id) 165 .fetch_optional(&state.db) 166 .await; 167 168 let current_root_cid = match repo_root_query { 169 Ok(Some(row)) => { 170 - let cid_str: String = row.get("repo_root_cid"); 171 match Cid::from_str(&cid_str) { 172 Ok(c) => c, 173 Err(_) => { ··· 449 } 450 }; 451 452 - let update_repo = sqlx::query("UPDATE repos SET repo_root_cid = $1 WHERE user_id = $2") 453 - .bind(new_root_cid.to_string()) 454 - .bind(user_id) 455 .execute(&state.db) 456 .await; 457 ··· 467 for (collection, rkey, record_cid) in record_ops { 468 match record_cid { 469 Some(cid) => { 470 - let _ = sqlx::query( 471 "INSERT INTO records (repo_id, collection, rkey, record_cid) VALUES ($1, $2, $3, $4) 472 ON CONFLICT (repo_id, collection, rkey) DO UPDATE SET record_cid = $4, created_at = NOW()", 473 ) 474 - .bind(user_id) 475 - .bind(&collection) 476 - .bind(&rkey) 477 - .bind(&cid) 478 .execute(&state.db) 479 .await; 480 } 481 None => { 482 - let _ = sqlx::query( 483 "DELETE FROM records WHERE repo_id = $1 AND collection = $2 AND rkey = $3", 484 ) 485 - .bind(user_id) 486 - .bind(&collection) 487 - .bind(&rkey) 488 .execute(&state.db) 489 .await; 490 }
··· 15 use jacquard_repo::{commit::Commit, mst::Mst, storage::BlockStore}; 16 use serde::{Deserialize, Serialize}; 17 use serde_json::json; 18 use std::str::FromStr; 19 use std::sync::Arc; 20 use tracing::error; ··· 89 .unwrap_or("") 90 .replace("Bearer ", ""); 91 92 + let session = sqlx::query!( 93 + "SELECT s.did, k.key_bytes FROM sessions s JOIN users u ON s.did = u.did JOIN user_keys k ON u.id = k.user_id WHERE s.access_jwt = $1", 94 + token 95 ) 96 .fetch_optional(&state.db) 97 .await 98 .unwrap_or(None); 99 100 let (did, key_bytes) = match session { 101 Some(row) => ( 102 + row.did, 103 + row.key_bytes, 104 ), 105 None => { 106 return ( ··· 143 .into_response(); 144 } 145 146 + let user_query = sqlx::query!("SELECT id FROM users WHERE did = $1", did) 147 .fetch_optional(&state.db) 148 .await; 149 150 let user_id: uuid::Uuid = match user_query { 151 + Ok(Some(row)) => row.id, 152 _ => { 153 return ( 154 StatusCode::INTERNAL_SERVER_ERROR, ··· 158 } 159 }; 160 161 + let repo_root_query = sqlx::query!("SELECT repo_root_cid FROM repos WHERE user_id = $1", user_id) 162 .fetch_optional(&state.db) 163 .await; 164 165 let current_root_cid = match repo_root_query { 166 Ok(Some(row)) => { 167 + let cid_str: String = row.repo_root_cid; 168 match Cid::from_str(&cid_str) { 169 Ok(c) => c, 170 Err(_) => { ··· 446 } 447 }; 448 449 + let update_repo = sqlx::query!("UPDATE repos SET repo_root_cid = $1 WHERE user_id = $2", new_root_cid.to_string(), user_id) 450 .execute(&state.db) 451 .await; 452 ··· 462 for (collection, rkey, record_cid) in record_ops { 463 match record_cid { 464 Some(cid) => { 465 + let _ = sqlx::query!( 466 "INSERT INTO records (repo_id, collection, rkey, record_cid) VALUES ($1, $2, $3, $4) 467 ON CONFLICT (repo_id, collection, rkey) DO UPDATE SET record_cid = $4, created_at = NOW()", 468 + user_id, 469 + collection, 470 + rkey, 471 + cid 472 ) 473 .execute(&state.db) 474 .await; 475 } 476 None => { 477 + let _ = sqlx::query!( 478 "DELETE FROM records WHERE repo_id = $1 AND collection = $2 AND rkey = $3", 479 + user_id, 480 + collection, 481 + rkey 482 ) 483 .execute(&state.db) 484 .await; 485 }
+11 -19
src/api/repo/record/delete.rs
··· 14 use jacquard_repo::{commit::Commit, mst::Mst, storage::BlockStore}; 15 use serde::Deserialize; 16 use serde_json::json; 17 - use sqlx::Row; 18 use std::str::FromStr; 19 use std::sync::Arc; 20 use tracing::error; ··· 49 .unwrap_or("") 50 .replace("Bearer ", ""); 51 52 - let session = sqlx::query( 53 - "SELECT s.did, k.key_bytes FROM sessions s JOIN users u ON s.did = u.did JOIN user_keys k ON u.id = k.user_id WHERE s.access_jwt = $1" 54 ) 55 - .bind(&token) 56 .fetch_optional(&state.db) 57 .await 58 .unwrap_or(None); 59 60 let (did, key_bytes) = match session { 61 Some(row) => ( 62 - row.get::<String, _>("did"), 63 - row.get::<Vec<u8>, _>("key_bytes"), 64 ), 65 None => { 66 return ( ··· 83 return (StatusCode::FORBIDDEN, Json(json!({"error": "InvalidRepo", "message": "Repo does not match authenticated user"}))).into_response(); 84 } 85 86 - let user_query = sqlx::query("SELECT id FROM users WHERE did = $1") 87 - .bind(&did) 88 .fetch_optional(&state.db) 89 .await; 90 91 let user_id: uuid::Uuid = match user_query { 92 - Ok(Some(row)) => row.get("id"), 93 _ => { 94 return ( 95 StatusCode::INTERNAL_SERVER_ERROR, ··· 99 } 100 }; 101 102 - let repo_root_query = sqlx::query("SELECT repo_root_cid FROM repos WHERE user_id = $1") 103 - .bind(user_id) 104 .fetch_optional(&state.db) 105 .await; 106 107 let current_root_cid = match repo_root_query { 108 Ok(Some(row)) => { 109 - let cid_str: String = row.get("repo_root_cid"); 110 Cid::from_str(&cid_str).ok() 111 } 112 _ => None, ··· 209 } 210 }; 211 212 - let update_repo = sqlx::query("UPDATE repos SET repo_root_cid = $1 WHERE user_id = $2") 213 - .bind(new_root_cid.to_string()) 214 - .bind(user_id) 215 .execute(&state.db) 216 .await; 217 ··· 225 } 226 227 let record_delete = 228 - sqlx::query("DELETE FROM records WHERE repo_id = $1 AND collection = $2 AND rkey = $3") 229 - .bind(user_id) 230 - .bind(&input.collection) 231 - .bind(&input.rkey) 232 .execute(&state.db) 233 .await; 234
··· 14 use jacquard_repo::{commit::Commit, mst::Mst, storage::BlockStore}; 15 use serde::Deserialize; 16 use serde_json::json; 17 use std::str::FromStr; 18 use std::sync::Arc; 19 use tracing::error; ··· 48 .unwrap_or("") 49 .replace("Bearer ", ""); 50 51 + let session = sqlx::query!( 52 + "SELECT s.did, k.key_bytes FROM sessions s JOIN users u ON s.did = u.did JOIN user_keys k ON u.id = k.user_id WHERE s.access_jwt = $1", 53 + token 54 ) 55 .fetch_optional(&state.db) 56 .await 57 .unwrap_or(None); 58 59 let (did, key_bytes) = match session { 60 Some(row) => ( 61 + row.did, 62 + row.key_bytes, 63 ), 64 None => { 65 return ( ··· 82 return (StatusCode::FORBIDDEN, Json(json!({"error": "InvalidRepo", "message": "Repo does not match authenticated user"}))).into_response(); 83 } 84 85 + let user_query = sqlx::query!("SELECT id FROM users WHERE did = $1", did) 86 .fetch_optional(&state.db) 87 .await; 88 89 let user_id: uuid::Uuid = match user_query { 90 + Ok(Some(row)) => row.id, 91 _ => { 92 return ( 93 StatusCode::INTERNAL_SERVER_ERROR, ··· 97 } 98 }; 99 100 + let repo_root_query = sqlx::query!("SELECT repo_root_cid FROM repos WHERE user_id = $1", user_id) 101 .fetch_optional(&state.db) 102 .await; 103 104 let current_root_cid = match repo_root_query { 105 Ok(Some(row)) => { 106 + let cid_str: String = row.repo_root_cid; 107 Cid::from_str(&cid_str).ok() 108 } 109 _ => None, ··· 206 } 207 }; 208 209 + let update_repo = sqlx::query!("UPDATE repos SET repo_root_cid = $1 WHERE user_id = $2", new_root_cid.to_string(), user_id) 210 .execute(&state.db) 211 .await; 212 ··· 220 } 221 222 let record_delete = 223 + sqlx::query!("DELETE FROM records WHERE repo_id = $1 AND collection = $2 AND rkey = $3", user_id, input.collection, input.rkey) 224 .execute(&state.db) 225 .await; 226
+68 -45
src/api/repo/record/read.rs
··· 9 use jacquard_repo::storage::BlockStore; 10 use serde::{Deserialize, Serialize}; 11 use serde_json::json; 12 - use sqlx::Row; 13 use std::str::FromStr; 14 use tracing::error; 15 ··· 25 State(state): State<AppState>, 26 Query(input): Query<GetRecordInput>, 27 ) -> Response { 28 - let user_row = if input.repo.starts_with("did:") { 29 - sqlx::query("SELECT id FROM users WHERE did = $1") 30 - .bind(&input.repo) 31 .fetch_optional(&state.db) 32 .await 33 } else { 34 - sqlx::query("SELECT id FROM users WHERE handle = $1") 35 - .bind(&input.repo) 36 .fetch_optional(&state.db) 37 .await 38 }; 39 40 - let user_id: uuid::Uuid = match user_row { 41 - Ok(Some(row)) => row.get("id"), 42 _ => { 43 return ( 44 StatusCode::NOT_FOUND, ··· 48 } 49 }; 50 51 - let record_row = sqlx::query( 52 "SELECT record_cid FROM records WHERE repo_id = $1 AND collection = $2 AND rkey = $3", 53 ) 54 - .bind(user_id) 55 - .bind(&input.collection) 56 - .bind(&input.rkey) 57 .fetch_optional(&state.db) 58 .await; 59 60 let record_cid_str: String = match record_row { 61 - Ok(Some(row)) => row.get("record_cid"), 62 _ => { 63 return ( 64 StatusCode::NOT_FOUND, ··· 143 State(state): State<AppState>, 144 Query(input): Query<ListRecordsInput>, 145 ) -> Response { 146 - let user_row = if input.repo.starts_with("did:") { 147 - sqlx::query("SELECT id FROM users WHERE did = $1") 148 - .bind(&input.repo) 149 .fetch_optional(&state.db) 150 .await 151 } else { 152 - sqlx::query("SELECT id FROM users WHERE handle = $1") 153 - .bind(&input.repo) 154 .fetch_optional(&state.db) 155 .await 156 }; 157 158 - let user_id: uuid::Uuid = match user_row { 159 - Ok(Some(row)) => row.get("id"), 160 _ => { 161 return ( 162 StatusCode::NOT_FOUND, ··· 172 // Simplistic query construction - no sophisticated cursor handling or rkey ranges for now, just basic pagination 173 // TODO: Implement rkeyStart/End and correct cursor logic 174 175 - let query_str = format!( 176 - "SELECT rkey, record_cid FROM records WHERE repo_id = $1 AND collection = $2 {} ORDER BY rkey {} LIMIT {}", 177 - if let Some(_c) = &input.cursor { 178 - if reverse { 179 - "AND rkey < $3" 180 - } else { 181 - "AND rkey > $3" 182 - } 183 } else { 184 - "" 185 - }, 186 - if reverse { "DESC" } else { "ASC" }, 187 - limit 188 - ); 189 - 190 - let mut query = sqlx::query(&query_str) 191 - .bind(user_id) 192 - .bind(&input.collection); 193 - 194 - if let Some(c) = &input.cursor { 195 - query = query.bind(c); 196 - } 197 198 - let rows = match query.fetch_all(&state.db).await { 199 Ok(r) => r, 200 Err(e) => { 201 error!("Error listing records: {:?}", e); ··· 210 let mut records = Vec::new(); 211 let mut last_rkey = None; 212 213 - for row in rows { 214 - let rkey: String = row.get("rkey"); 215 - let cid_str: String = row.get("record_cid"); 216 last_rkey = Some(rkey.clone()); 217 218 if let Ok(cid) = Cid::from_str(&cid_str) {
··· 9 use jacquard_repo::storage::BlockStore; 10 use serde::{Deserialize, Serialize}; 11 use serde_json::json; 12 use std::str::FromStr; 13 use tracing::error; 14 ··· 24 State(state): State<AppState>, 25 Query(input): Query<GetRecordInput>, 26 ) -> Response { 27 + let user_id_opt = if input.repo.starts_with("did:") { 28 + sqlx::query!("SELECT id FROM users WHERE did = $1", input.repo) 29 .fetch_optional(&state.db) 30 .await 31 + .map(|opt| opt.map(|r| r.id)) 32 } else { 33 + sqlx::query!("SELECT id FROM users WHERE handle = $1", input.repo) 34 .fetch_optional(&state.db) 35 .await 36 + .map(|opt| opt.map(|r| r.id)) 37 }; 38 39 + let user_id: uuid::Uuid = match user_id_opt { 40 + Ok(Some(id)) => id, 41 _ => { 42 return ( 43 StatusCode::NOT_FOUND, ··· 47 } 48 }; 49 50 + let record_row = sqlx::query!( 51 "SELECT record_cid FROM records WHERE repo_id = $1 AND collection = $2 AND rkey = $3", 52 + user_id, 53 + input.collection, 54 + input.rkey 55 ) 56 .fetch_optional(&state.db) 57 .await; 58 59 let record_cid_str: String = match record_row { 60 + Ok(Some(row)) => row.record_cid, 61 _ => { 62 return ( 63 StatusCode::NOT_FOUND, ··· 142 State(state): State<AppState>, 143 Query(input): Query<ListRecordsInput>, 144 ) -> Response { 145 + let user_id_opt = if input.repo.starts_with("did:") { 146 + sqlx::query!("SELECT id FROM users WHERE did = $1", input.repo) 147 .fetch_optional(&state.db) 148 .await 149 + .map(|opt| opt.map(|r| r.id)) 150 } else { 151 + sqlx::query!("SELECT id FROM users WHERE handle = $1", input.repo) 152 .fetch_optional(&state.db) 153 .await 154 + .map(|opt| opt.map(|r| r.id)) 155 }; 156 157 + let user_id: uuid::Uuid = match user_id_opt { 158 + Ok(Some(id)) => id, 159 _ => { 160 return ( 161 StatusCode::NOT_FOUND, ··· 171 // Simplistic query construction - no sophisticated cursor handling or rkey ranges for now, just basic pagination 172 // TODO: Implement rkeyStart/End and correct cursor logic 173 174 + let limit_i64 = limit as i64; 175 + let rows_res = if let Some(cursor) = &input.cursor { 176 + if reverse { 177 + sqlx::query!( 178 + "SELECT rkey, record_cid FROM records WHERE repo_id = $1 AND collection = $2 AND rkey < $3 ORDER BY rkey DESC LIMIT $4", 179 + user_id, 180 + input.collection, 181 + cursor, 182 + limit_i64 183 + ) 184 + .fetch_all(&state.db) 185 + .await 186 + .map(|rows| rows.into_iter().map(|r| (r.rkey, r.record_cid)).collect::<Vec<_>>()) 187 + } else { 188 + sqlx::query!( 189 + "SELECT rkey, record_cid FROM records WHERE repo_id = $1 AND collection = $2 AND rkey > $3 ORDER BY rkey ASC LIMIT $4", 190 + user_id, 191 + input.collection, 192 + cursor, 193 + limit_i64 194 + ) 195 + .fetch_all(&state.db) 196 + .await 197 + .map(|rows| rows.into_iter().map(|r| (r.rkey, r.record_cid)).collect::<Vec<_>>()) 198 + } 199 + } else { 200 + if reverse { 201 + sqlx::query!( 202 + "SELECT rkey, record_cid FROM records WHERE repo_id = $1 AND collection = $2 ORDER BY rkey DESC LIMIT $3", 203 + user_id, 204 + input.collection, 205 + limit_i64 206 + ) 207 + .fetch_all(&state.db) 208 + .await 209 + .map(|rows| rows.into_iter().map(|r| (r.rkey, r.record_cid)).collect::<Vec<_>>()) 210 } else { 211 + sqlx::query!( 212 + "SELECT rkey, record_cid FROM records WHERE repo_id = $1 AND collection = $2 ORDER BY rkey ASC LIMIT $3", 213 + user_id, 214 + input.collection, 215 + limit_i64 216 + ) 217 + .fetch_all(&state.db) 218 + .await 219 + .map(|rows| rows.into_iter().map(|r| (r.rkey, r.record_cid)).collect::<Vec<_>>()) 220 + } 221 + }; 222 223 + let rows = match rows_res { 224 Ok(r) => r, 225 Err(e) => { 226 error!("Error listing records: {:?}", e); ··· 235 let mut records = Vec::new(); 236 let mut last_rkey = None; 237 238 + for (rkey, cid_str) in rows { 239 last_rkey = Some(rkey.clone()); 240 241 if let Ok(cid) = Cid::from_str(&cid_str) {
+30 -39
src/api/repo/record/write.rs
··· 15 use jacquard_repo::{commit::Commit, mst::Mst, storage::BlockStore}; 16 use serde::{Deserialize, Serialize}; 17 use serde_json::json; 18 - use sqlx::Row; 19 use std::str::FromStr; 20 use std::sync::Arc; 21 use tracing::error; ··· 58 .unwrap_or("") 59 .replace("Bearer ", ""); 60 61 - let session = sqlx::query( 62 - "SELECT s.did, k.key_bytes FROM sessions s JOIN users u ON s.did = u.did JOIN user_keys k ON u.id = k.user_id WHERE s.access_jwt = $1" 63 ) 64 - .bind(&token) 65 .fetch_optional(&state.db) 66 .await 67 .unwrap_or(None); 68 69 let (did, key_bytes) = match session { 70 Some(row) => ( 71 - row.get::<String, _>("did"), 72 - row.get::<Vec<u8>, _>("key_bytes"), 73 ), 74 None => { 75 return ( ··· 92 return (StatusCode::FORBIDDEN, Json(json!({"error": "InvalidRepo", "message": "Repo does not match authenticated user"}))).into_response(); 93 } 94 95 - let user_query = sqlx::query("SELECT id FROM users WHERE did = $1") 96 - .bind(&did) 97 .fetch_optional(&state.db) 98 .await; 99 100 let user_id: uuid::Uuid = match user_query { 101 - Ok(Some(row)) => row.get("id"), 102 _ => { 103 return ( 104 StatusCode::INTERNAL_SERVER_ERROR, ··· 108 } 109 }; 110 111 - let repo_root_query = sqlx::query("SELECT repo_root_cid FROM repos WHERE user_id = $1") 112 - .bind(user_id) 113 .fetch_optional(&state.db) 114 .await; 115 116 let current_root_cid = match repo_root_query { 117 Ok(Some(row)) => { 118 - let cid_str: String = row.get("repo_root_cid"); 119 Cid::from_str(&cid_str).ok() 120 } 121 _ => None, ··· 280 } 281 }; 282 283 - let update_repo = sqlx::query("UPDATE repos SET repo_root_cid = $1 WHERE user_id = $2") 284 - .bind(new_root_cid.to_string()) 285 - .bind(user_id) 286 .execute(&state.db) 287 .await; 288 ··· 295 .into_response(); 296 } 297 298 - let record_insert = sqlx::query( 299 "INSERT INTO records (repo_id, collection, rkey, record_cid) VALUES ($1, $2, $3, $4) 300 ON CONFLICT (repo_id, collection, rkey) DO UPDATE SET record_cid = $4, created_at = NOW()", 301 ) 302 - .bind(user_id) 303 - .bind(&input.collection) 304 - .bind(&rkey) 305 - .bind(record_cid.to_string()) 306 .execute(&state.db) 307 .await; 308 ··· 362 .unwrap_or("") 363 .replace("Bearer ", ""); 364 365 - let session = sqlx::query( 366 - "SELECT s.did, k.key_bytes FROM sessions s JOIN users u ON s.did = u.did JOIN user_keys k ON u.id = k.user_id WHERE s.access_jwt = $1" 367 ) 368 - .bind(&token) 369 .fetch_optional(&state.db) 370 .await 371 .unwrap_or(None); 372 373 let (did, key_bytes) = match session { 374 Some(row) => ( 375 - row.get::<String, _>("did"), 376 - row.get::<Vec<u8>, _>("key_bytes"), 377 ), 378 None => { 379 return ( ··· 396 return (StatusCode::FORBIDDEN, Json(json!({"error": "InvalidRepo", "message": "Repo does not match authenticated user"}))).into_response(); 397 } 398 399 - let user_query = sqlx::query("SELECT id FROM users WHERE did = $1") 400 - .bind(&did) 401 .fetch_optional(&state.db) 402 .await; 403 404 let user_id: uuid::Uuid = match user_query { 405 - Ok(Some(row)) => row.get("id"), 406 _ => { 407 return ( 408 StatusCode::INTERNAL_SERVER_ERROR, ··· 412 } 413 }; 414 415 - let repo_root_query = sqlx::query("SELECT repo_root_cid FROM repos WHERE user_id = $1") 416 - .bind(user_id) 417 .fetch_optional(&state.db) 418 .await; 419 420 let current_root_cid = match repo_root_query { 421 Ok(Some(row)) => { 422 - let cid_str: String = row.get("repo_root_cid"); 423 Cid::from_str(&cid_str).ok() 424 } 425 _ => None, ··· 637 } 638 }; 639 640 - let update_repo = sqlx::query("UPDATE repos SET repo_root_cid = $1 WHERE user_id = $2") 641 - .bind(new_root_cid.to_string()) 642 - .bind(user_id) 643 .execute(&state.db) 644 .await; 645 ··· 652 .into_response(); 653 } 654 655 - let record_insert = sqlx::query( 656 "INSERT INTO records (repo_id, collection, rkey, record_cid) VALUES ($1, $2, $3, $4) 657 ON CONFLICT (repo_id, collection, rkey) DO UPDATE SET record_cid = $4, created_at = NOW()", 658 ) 659 - .bind(user_id) 660 - .bind(&input.collection) 661 - .bind(&rkey) 662 - .bind(record_cid.to_string()) 663 .execute(&state.db) 664 .await; 665
··· 15 use jacquard_repo::{commit::Commit, mst::Mst, storage::BlockStore}; 16 use serde::{Deserialize, Serialize}; 17 use serde_json::json; 18 use std::str::FromStr; 19 use std::sync::Arc; 20 use tracing::error; ··· 57 .unwrap_or("") 58 .replace("Bearer ", ""); 59 60 + let session = sqlx::query!( 61 + "SELECT s.did, k.key_bytes FROM sessions s JOIN users u ON s.did = u.did JOIN user_keys k ON u.id = k.user_id WHERE s.access_jwt = $1", 62 + token 63 ) 64 .fetch_optional(&state.db) 65 .await 66 .unwrap_or(None); 67 68 let (did, key_bytes) = match session { 69 Some(row) => ( 70 + row.did, 71 + row.key_bytes, 72 ), 73 None => { 74 return ( ··· 91 return (StatusCode::FORBIDDEN, Json(json!({"error": "InvalidRepo", "message": "Repo does not match authenticated user"}))).into_response(); 92 } 93 94 + let user_query = sqlx::query!("SELECT id FROM users WHERE did = $1", did) 95 .fetch_optional(&state.db) 96 .await; 97 98 let user_id: uuid::Uuid = match user_query { 99 + Ok(Some(row)) => row.id, 100 _ => { 101 return ( 102 StatusCode::INTERNAL_SERVER_ERROR, ··· 106 } 107 }; 108 109 + let repo_root_query = sqlx::query!("SELECT repo_root_cid FROM repos WHERE user_id = $1", user_id) 110 .fetch_optional(&state.db) 111 .await; 112 113 let current_root_cid = match repo_root_query { 114 Ok(Some(row)) => { 115 + let cid_str: String = row.repo_root_cid; 116 Cid::from_str(&cid_str).ok() 117 } 118 _ => None, ··· 277 } 278 }; 279 280 + let update_repo = sqlx::query!("UPDATE repos SET repo_root_cid = $1 WHERE user_id = $2", new_root_cid.to_string(), user_id) 281 .execute(&state.db) 282 .await; 283 ··· 290 .into_response(); 291 } 292 293 + let record_insert = sqlx::query!( 294 "INSERT INTO records (repo_id, collection, rkey, record_cid) VALUES ($1, $2, $3, $4) 295 ON CONFLICT (repo_id, collection, rkey) DO UPDATE SET record_cid = $4, created_at = NOW()", 296 + user_id, 297 + input.collection, 298 + rkey, 299 + record_cid.to_string() 300 ) 301 .execute(&state.db) 302 .await; 303 ··· 357 .unwrap_or("") 358 .replace("Bearer ", ""); 359 360 + let session = sqlx::query!( 361 + "SELECT s.did, k.key_bytes FROM sessions s JOIN users u ON s.did = u.did JOIN user_keys k ON u.id = k.user_id WHERE s.access_jwt = $1", 362 + token 363 ) 364 .fetch_optional(&state.db) 365 .await 366 .unwrap_or(None); 367 368 let (did, key_bytes) = match session { 369 Some(row) => ( 370 + row.did, 371 + row.key_bytes, 372 ), 373 None => { 374 return ( ··· 391 return (StatusCode::FORBIDDEN, Json(json!({"error": "InvalidRepo", "message": "Repo does not match authenticated user"}))).into_response(); 392 } 393 394 + let user_query = sqlx::query!("SELECT id FROM users WHERE did = $1", did) 395 .fetch_optional(&state.db) 396 .await; 397 398 let user_id: uuid::Uuid = match user_query { 399 + Ok(Some(row)) => row.id, 400 _ => { 401 return ( 402 StatusCode::INTERNAL_SERVER_ERROR, ··· 406 } 407 }; 408 409 + let repo_root_query = sqlx::query!("SELECT repo_root_cid FROM repos WHERE user_id = $1", user_id) 410 .fetch_optional(&state.db) 411 .await; 412 413 let current_root_cid = match repo_root_query { 414 Ok(Some(row)) => { 415 + let cid_str: String = row.repo_root_cid; 416 Cid::from_str(&cid_str).ok() 417 } 418 _ => None, ··· 630 } 631 }; 632 633 + let update_repo = sqlx::query!("UPDATE repos SET repo_root_cid = $1 WHERE user_id = $2", new_root_cid.to_string(), user_id) 634 .execute(&state.db) 635 .await; 636 ··· 643 .into_response(); 644 } 645 646 + let record_insert = sqlx::query!( 647 "INSERT INTO records (repo_id, collection, rkey, record_cid) VALUES ($1, $2, $3, $4) 648 ON CONFLICT (repo_id, collection, rkey) DO UPDATE SET record_cid = $4, created_at = NOW()", 649 + user_id, 650 + input.collection, 651 + rkey, 652 + record_cid.to_string() 653 ) 654 .execute(&state.db) 655 .await; 656