Loading packages/server/prisma/dbml/schema.dbml +11 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,9 @@ Table Setting { Table User { sub String [pk] picture_url String display_name String profile_url String lastPixelTime DateTime [default: `now()`, not null] pixelStack Int [not null, default: 0] undoExpires DateTime Loading @@ -18,6 +21,14 @@ Table User { FactionMember FactionMember [not null] } Table Instance { id Int [pk, increment] hostname String [unique, not null] name String logo_url String banner_url String } Table PaletteColor { id Int [pk, increment] name String [not null] Loading packages/server/prisma/migrations/20240531195901_add_profile_and_instance_metadata/migration.sql 0 → 100644 +18 −0 Original line number Diff line number Diff line -- AlterTable ALTER TABLE "User" ADD COLUMN "display_name" TEXT, ADD COLUMN "picture_url" TEXT, ADD COLUMN "profile_url" TEXT; -- CreateTable CREATE TABLE "Instance" ( "id" SERIAL NOT NULL, "hostname" TEXT NOT NULL, "name" TEXT, "logo_url" TEXT, "banner_url" TEXT, CONSTRAINT "Instance_pkey" PRIMARY KEY ("id") ); -- CreateIndex CREATE UNIQUE INDEX "Instance_hostname_key" ON "Instance"("hostname"); packages/server/prisma/schema.prisma +13 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,10 @@ model Setting { model User { sub String @id display_name String? picture_url String? profile_url String? lastPixelTime DateTime @default(now()) // the time the last pixel was placed at pixelStack Int @default(0) // amount of pixels stacked for this user undoExpires DateTime? // when the undo for the most recent pixel expires at Loading @@ -32,6 +36,14 @@ model User { FactionMember FactionMember[] } model Instance { id Int @id @default(autoincrement()) hostname String @unique name String? logo_url String? banner_url String? } model PaletteColor { id Int @id @default(autoincrement()) name String Loading packages/server/src/api/client.ts +31 −3 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ import { prisma } from "../lib/prisma"; import { OpenID } from "../lib/oidc"; import { TokenSet, errors as OIDC_Errors } from "openid-client"; import { Logger } from "../lib/Logger"; import Canvas from "../lib/Canvas"; const ClientParams = { TYPE: "auth_type", Loading Loading @@ -135,13 +136,40 @@ app.get("/callback", async (req, res) => { const [username, hostname] = whoami.sub.split("@"); const sub = [username, hostname].join("@"); await prisma.user.upsert({ where: { sub: [username, hostname].join("@"), sub, }, update: { sub, display_name: whoami.name, picture_url: whoami.picture, profile_url: whoami.profile, }, update: {}, create: { sub: [username, hostname].join("@"), sub, display_name: whoami.name, picture_url: whoami.picture, profile_url: whoami.profile, }, }); await prisma.instance.upsert({ where: { hostname, }, update: { hostname, name: whoami.instance.instance.name, logo_url: whoami.instance.instance.logo_uri, banner_url: whoami.instance.instance.banner_uri, }, create: { hostname, name: whoami.instance.instance.name, logo_url: whoami.instance.instance.logo_uri, banner_url: whoami.instance.instance.banner_uri, }, }); Loading Loading
packages/server/prisma/dbml/schema.dbml +11 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,9 @@ Table Setting { Table User { sub String [pk] picture_url String display_name String profile_url String lastPixelTime DateTime [default: `now()`, not null] pixelStack Int [not null, default: 0] undoExpires DateTime Loading @@ -18,6 +21,14 @@ Table User { FactionMember FactionMember [not null] } Table Instance { id Int [pk, increment] hostname String [unique, not null] name String logo_url String banner_url String } Table PaletteColor { id Int [pk, increment] name String [not null] Loading
packages/server/prisma/migrations/20240531195901_add_profile_and_instance_metadata/migration.sql 0 → 100644 +18 −0 Original line number Diff line number Diff line -- AlterTable ALTER TABLE "User" ADD COLUMN "display_name" TEXT, ADD COLUMN "picture_url" TEXT, ADD COLUMN "profile_url" TEXT; -- CreateTable CREATE TABLE "Instance" ( "id" SERIAL NOT NULL, "hostname" TEXT NOT NULL, "name" TEXT, "logo_url" TEXT, "banner_url" TEXT, CONSTRAINT "Instance_pkey" PRIMARY KEY ("id") ); -- CreateIndex CREATE UNIQUE INDEX "Instance_hostname_key" ON "Instance"("hostname");
packages/server/prisma/schema.prisma +13 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,10 @@ model Setting { model User { sub String @id display_name String? picture_url String? profile_url String? lastPixelTime DateTime @default(now()) // the time the last pixel was placed at pixelStack Int @default(0) // amount of pixels stacked for this user undoExpires DateTime? // when the undo for the most recent pixel expires at Loading @@ -32,6 +36,14 @@ model User { FactionMember FactionMember[] } model Instance { id Int @id @default(autoincrement()) hostname String @unique name String? logo_url String? banner_url String? } model PaletteColor { id Int @id @default(autoincrement()) name String Loading
packages/server/src/api/client.ts +31 −3 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ import { prisma } from "../lib/prisma"; import { OpenID } from "../lib/oidc"; import { TokenSet, errors as OIDC_Errors } from "openid-client"; import { Logger } from "../lib/Logger"; import Canvas from "../lib/Canvas"; const ClientParams = { TYPE: "auth_type", Loading Loading @@ -135,13 +136,40 @@ app.get("/callback", async (req, res) => { const [username, hostname] = whoami.sub.split("@"); const sub = [username, hostname].join("@"); await prisma.user.upsert({ where: { sub: [username, hostname].join("@"), sub, }, update: { sub, display_name: whoami.name, picture_url: whoami.picture, profile_url: whoami.profile, }, update: {}, create: { sub: [username, hostname].join("@"), sub, display_name: whoami.name, picture_url: whoami.picture, profile_url: whoami.profile, }, }); await prisma.instance.upsert({ where: { hostname, }, update: { hostname, name: whoami.instance.instance.name, logo_url: whoami.instance.instance.logo_uri, banner_url: whoami.instance.instance.banner_uri, }, create: { hostname, name: whoami.instance.instance.name, logo_url: whoami.instance.instance.logo_uri, banner_url: whoami.instance.instance.banner_uri, }, }); Loading