data
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
|||||||
MANIFEST-000013
|
MANIFEST-000040
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,12 @@
|
|||||||
|
DEFINE FUNCTION auth::sessiontoken::new($user: uuid) {
|
||||||
|
LET $token = rand::string(64);
|
||||||
|
|
||||||
|
CREATE SessionToken CONTENT {
|
||||||
|
id: rand::uuid::v4(),
|
||||||
|
created: time::now(),
|
||||||
|
expires: time::now() + 7d,
|
||||||
|
token: $token,
|
||||||
|
user: Entity:user,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,26 +1,28 @@
|
|||||||
DEFINE FUNCTION friend::request($from: uuid, $to: uuid) {
|
DEFINE FUNCTION friend::request($from: uuid, $to: uuid) {
|
||||||
CREATE FriendRequest SET
|
RELATE Entity:from -> FriendRequest -> Entity:to
|
||||||
in = Entity:from,
|
content {
|
||||||
out = Entity:to,
|
created = time::now()
|
||||||
created = time::now(),
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE FUNCTION friend::accept($request: record<FriendRequest>) {
|
DEFINE FUNCTION friend::accept($from: uuid, $to: uuid) {
|
||||||
|
|
||||||
LET $fsid = uuid::new();
|
-- check if there is a friend request
|
||||||
|
|
||||||
CREATE Friendship SET
|
IF !HasFriendRequest WHERE out = Entity:from AND in = Entity:to {
|
||||||
dm_channel = channel::new(),
|
RETURN;
|
||||||
id = $fsid,
|
}
|
||||||
since = time::now(),
|
|
||||||
|
|
||||||
CREATE HasFriendShip SET
|
LET $fsid: uuid = rand::uuid::v4();
|
||||||
in = Entity:request.in,
|
CREATE Friendship SET id = $fsid, channel_id = fn::channel::new(), since = time::now();
|
||||||
out = Friendship:fsid,
|
RELATE Entity:from -> HasFriendship -> Friendship:fsid CONTENT { nickname = Entity:from.displayname };
|
||||||
nickname = Entity:request.out.displayname,
|
RELATE Entity:to -> HasFriendship -> Friendship:fsid CONTENT { nickname = Entity:to.displayname };
|
||||||
|
}
|
||||||
|
|
||||||
CREATE HasFriendShip SET
|
DEFINE FUNCTION friend::reject($from: uuid, $to: uuid) {
|
||||||
in = Entity:request.out,
|
DELETE Entity:from -> FriendRequest WHERE out = Entity:to
|
||||||
out = Friendship:fsid,
|
}
|
||||||
nickname = Entity:request.in.displayname,
|
|
||||||
|
DEFINE FUNCTION friend::remove($from: uuid, $to: uuid) {
|
||||||
|
DELETE Entity:from -> HasFriendship -> Friendship WHERE <- HasFriendship.out <- Entity:to
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
DEFINE FUNCTION icon::default() {
|
||||||
|
RETURN "/static/public/server_default.png";
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,11 +1,26 @@
|
|||||||
DEFINE FUNCTION server::join($server_id: uuid, $entity_id: uuid) {
|
DEFINE FUNCTION server::join($server: uuid, $entity: uuid) {
|
||||||
|
LET $user = (SELECT displayname FROM Entity WHERE id = $entity);
|
||||||
|
RELATE Entity:entity -> HasServer -> Server:server CONTENT {
|
||||||
|
joined: time::now(),
|
||||||
|
nickname: $user.displayname
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
LET $user = (SELECT displayname FROM Entity WHERE id = $entity_id)[0];
|
DEFINE FUNCTION server::leave($server: uuid, $entity: uuid) {
|
||||||
|
DELETE HasServer WHERE out = Server:server AND in = Entity:entity;
|
||||||
|
DELETE HasRole WHERE in = Entity:entity AND ->Role.server = Server:server;
|
||||||
|
}
|
||||||
|
|
||||||
CREATE HasServer SET
|
DEFINE FUNCTION server::new($name: string, $creator: uuid) {
|
||||||
in = Entity:entity_id,
|
LET $id = rand::uuid::v4();
|
||||||
out = Server:server_id,
|
|
||||||
nickname = $user.displayname,
|
CREATE Server CONTENT {
|
||||||
permissions = [],
|
created: time::now(),
|
||||||
joined = time::now(),
|
name: $name,
|
||||||
|
owner: $creator,
|
||||||
|
id: $id,
|
||||||
|
icon_uri: fn::icon::default(),
|
||||||
|
};
|
||||||
|
|
||||||
|
fn::server::join($id, $creator)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user