This commit is contained in:
FantasyPvP
2024-12-02 17:39:27 +00:00
parent 0ae26d46bf
commit 1707309d95
17 changed files with 60 additions and 27 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
MANIFEST-000013 MANIFEST-000040
Binary file not shown.
Binary file not shown.
+12
View File
@@ -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,
};
}
View File
+20 -18
View File
@@ -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
} }
+4
View File
@@ -0,0 +1,4 @@
DEFINE FUNCTION icon::default() {
RETURN "/static/public/server_default.png";
}
+23 -8
View File
@@ -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)
} }