-
Notifications
You must be signed in to change notification settings - Fork 3
/
addUser.rho
28 lines (28 loc) · 1.26 KB
/
addUser.rho
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#define $directory "testdir"
#define $username "jimscarver"
new ret, ret1, lookup(`rho:registry:lookup`), stdout(`rho:io:stdout`) in {
lookup!($locker_%%$myusername, *ret) | for(locker <- ret) {
locker!("get", $myprivkey.hexToBytes(), $locker_nonce_%%$myusername, *stdout, *ret) |
for (@items <- ret) {
/* stdout!(items) | */
if ( items.get("peek") == Nil ) {
stdout!("you do not have an mailbox")
} else {
stdout!("finding " ++ $directory ++ " in inbox of " ++ $myusername) |
@{items.get("peek")}!("directory", $directory,*ret) |
for ( @[{"read": *read, "write": *write, "grant": grant, ..._ }, ..._] <- ret ) {
if ( *write == Nil ) {
stdout!("you do not have permission to write to " ++ $directory)
} else {
lookup!($inbox_%%$username,*ret) |
@grant!($username, *ret1) |
for( inbox <- ret; changekey <- ret1 ) {
stdout!("adding " ++ $username) |
write!($username,*inbox, *stdout) |
inbox!(["directory", $directory,
{"read": *read, "changekey": *changekey}], *stdout)
}
}
} } |
stdout!(["#define $locker_nonce_" ++ $myusername, {$locker_nonce_%%$myusername + 1}])
} } }