Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dunixir
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
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RUANO RINCON Santiago
dunixir
Commits
e0a01546
Commit
e0a01546
authored
4 years ago
by
FERRIEUX Etienne
Browse files
Options
Downloads
Patches
Plain Diff
added constraint on id db
parent
370f62e4
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
simple_server/lib/simple_server/simple_server_router.ex
+13
-5
13 additions, 5 deletions
simple_server/lib/simple_server/simple_server_router.ex
simple_server/priv/repo/migrations/20201102160447_create_ids.exs
+2
-0
2 additions, 0 deletions
...server/priv/repo/migrations/20201102160447_create_ids.exs
with
15 additions
and
5 deletions
simple_server/lib/simple_server/simple_server_router.ex
+
13
−
5
View file @
e0a01546
...
...
@@ -47,13 +47,21 @@ defmodule SimpleServer.Router do
{
:ok
,
body
,
conn
}
=
read_body
(
conn
)
body
=
Poison
.
decode!
(
body
)
id
=
%
Identity
{
uid:
body
[
"uid"
],
pubkey:
body
[
"pubkey"
],
member:
body
[
"member"
]}
Repo
.
insert
(
id
)
changeset
=
Identity
.
changeset
(%
Identity
{},%{
uid:
body
[
"uid"
],
pubkey:
body
[
"pubkey"
],
member:
body
[
"member"
]})
result
=
Repo
.
insert
(
changeset
)
case
result
do
{
:error
,
changeset
}
->
send_resp
(
conn
,
301
,
"failed creation:
#{
inspect
changeset
}
"
)
_
->
DynamicSupervisor
.
start_child
(
Identity
.
DynamicSupervisor
,
%{
id:
body
[
"pubkey"
],
start:
{
IDGenserver
,
:start
,
[
body
[
"pubkey"
]]}})
# We insert the Identity in the db and start the genserver that will its certifications.
send_resp
(
conn
,
201
,
"created:
#{
inspect
id
}
"
)
send_resp
(
conn
,
201
,
"created:
#{
inspect
changeset
}
"
)
end
end
...
...
This diff is collapsed.
Click to expand it.
simple_server/priv/repo/migrations/20201102160447_create_ids.exs
+
2
−
0
View file @
e0a01546
...
...
@@ -7,5 +7,7 @@ defmodule Duniter.Repo.Migrations.CreateIds do
add
:pubkey
,
:string
add
:member
,
:boolean
end
create
unique_index
(
:identities
,
[
:uid
])
create
unique_index
(
:identities
,
[
:pubkey
])
end
end
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