summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2019-01-11 18:25:05 +0100
committernsensfel <SpamShield0@noot-noot.org>2019-01-11 18:25:05 +0100
commit8fe85396104a2eeddda620a670a275a8ace1b605 (patch)
treece9cfa009a819f553beedff8d9f7e2328b89d0ad /src/bounty
parent992c6788db73837a503bdc3c8f8a17d6357c224e (diff)
...
Diffstat (limited to 'src/bounty')
-rw-r--r--src/bounty/struct/bnt_bounty.erl31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/bounty/struct/bnt_bounty.erl b/src/bounty/struct/bnt_bounty.erl
index 0d7df47..4ede9b0 100644
--- a/src/bounty/struct/bnt_bounty.erl
+++ b/src/bounty/struct/bnt_bounty.erl
@@ -27,7 +27,7 @@
(
[
generate/4,
- execute/1
+ resolve/0
]
).
@@ -54,10 +54,11 @@
ataxia_time:type(),
job()
)
- -> 'ok'.
+ -> {'ok', ataxia_id:type()}.
generate (User, NotBefore, Deadline, Job) ->
Janitor = ataxia_security:janitor(),
JanitorOnly = ataxia_security:allow_only(Janitor),
+ JanitorAndUser = ataxia_security:add_access(User, JanitorOnly),
Bounty =
{
@@ -66,22 +67,34 @@ generate (User, NotBefore, Deadline, Job) ->
job = Job
},
- {ok, _BountyID} =
+ {ok, BountyID} =
ataxia_client:add
(
bounty_db,
- JanitorOnly,
- JanitorOnly,
+ JanitorAndUser,
+ JanitorAndUser,
ataxia_lock:locked(User, NotBefore),
Bounty
),
- ok.
+ {ok, BountyID}.
+
+-spec resolve () -> type().
+resolve () ->
+ Lock = ataxia_lock:locked(ataxia_security:admin(), 60),
+
+ {ok, BountyID, Bounty} =
+ ataxia_client:update_and_fetch_any
+ (
+ bounty_db,
+ ataxia_security:janitor(),
+ ataxic:update_lock(ataxic:constant(Lock)),
+ ataxic:constant(true)
+ ),
--spec execute (type()) -> any().
-execute (Bounty) ->
{Module, Function, Params} = Bounty#bounty.job,
- erlang:apply(Module, Function, Params).
+
+ erlang:apply(Module, Function, [BountyID|Params]).
-spec get_deadline (type()) -> ataxia_time:type().
get_deadline (Bounty) -> Bounty#bounty.deadline.