Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Duniter Datapod
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
Duniter Datapod
Commits
b3ca1251
Commit
b3ca1251
authored
5 months ago
by
Hugo Trentesaux
Browse files
Options
Downloads
Patches
Plain Diff
add a tiny bit of content validation to prevent overloading database
parent
95cdec7b
No related branches found
Branches containing commit
Tags
0.1.0-a0.1
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/indexer/database.ts
+16
-38
16 additions, 38 deletions
src/indexer/database.ts
with
16 additions
and
38 deletions
src/indexer/database.ts
+
16
−
38
View file @
b3ca1251
...
...
@@ -87,10 +87,13 @@ const userFsQb: QueryBuilder = {
data_cid = EXCLUDED.data_cid,
WHERE EXCLUDED.time > profiles.time;
`
,
// we do not need to fetch any data
dataGetter
:
(
_dataCID
)
=>
Promise
.
resolve
(
null
),
// we do not *need* to fetch any data
// however, we do fetch the first node to make sure it becomes available locally
// this is the place where we could fetch more specific parts of this FS
// to be sure to make them available on the network for later
dataGetter
:
defaultDataGetter
,
dataTransform
:
defaultDataTransform
,
paramBuilder
:
(
irCID
:
CID
,
ir
:
IndexRequest
,
dataCID
:
CID
,
_data
:
null
)
=>
[
paramBuilder
:
(
irCID
:
CID
,
ir
:
IndexRequest
,
dataCID
:
CID
,
_data
:
any
)
=>
[
// $1 index_request_cid
irCID
.
toString
(),
// $2 time
...
...
@@ -133,20 +136,20 @@ const cesiumPlusProfile: QueryBuilder = {
ir
.
pubkey
,
// $4 data_cid
dataCID
.
toString
(),
// $5 title
data
.
title
,
// $6 description
data
.
description
,
// $7 avatar
data
.
avatar
?.
toString
(),
// $5 title
(truncated to 128 chars)
data
.
title
.
substring
(
0
,
128
)
,
// $6 description
(truncated to 1024 chars, full version still available on IPFS)
data
.
description
.
substring
(
0
,
1024
)
,
// $7 avatar
(makes sure it is not more than a reasonable CID)
data
.
avatar
?.
toString
()
.
substring
(
0
,
64
)
,
// $8 geoloc
data
.
geoPoint
?.
lat
,
// $9
data
.
geoPoint
?.
lon
,
// $10 city
data
.
city
,
// $11 socials
data
.
socials
?
JSON
.
stringify
(
data
.
socials
)
:
undefined
// $10 city
(truncated to 128 chars)
data
.
city
?.
toString
().
substring
(
0
,
128
)
,
// $11 socials
(json truncated to 4096 chars, full version available on IPFS, research in json is unlikely)
data
.
socials
?
JSON
.
stringify
(
data
.
socials
)
.
substring
(
0
,
4096
)
:
undefined
]
}
...
...
@@ -183,31 +186,6 @@ const cesiumPlusProfileRaw: QueryBuilder = {
paramBuilder
:
cesiumPlusProfile
.
paramBuilder
}
// transaction comment query and param builder
// prevents overwrite
const
txComment
:
QueryBuilder
=
{
query
:
`INSERT INTO
transaction_comments(index_request_cid, time, pubkey, tx_id, comment)
VALUES ($1, $2, $3, $4, $5)
ON CONFLICT (pubkey, tx_id)
DO NOTHING;
`
,
dataGetter
:
defaultDataGetter
,
dataTransform
:
defaultDataTransform
,
paramBuilder
:
(
irCID
:
CID
,
ir
:
IndexRequest
,
_dataCID
:
CID
,
data
:
TxComment
)
=>
[
// $1 index_request_cid
irCID
.
toString
(),
// $2 time
new
Date
(
ir
.
time
).
toISOString
(),
// $3 pubkey
ir
.
pubkey
,
// $4 tx_id
data
.
tx_id
,
// $5 comment
data
.
comment
]
}
/// return data handler for a query builder
const
dataHandler
:
<
T
>
(
q
:
QueryBuilder
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment