add instance & profile metadata
This commit is contained in:
parent
0f545ee233
commit
235bc0b6ca
|
@ -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
|
||||
|
@ -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]
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
-- 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");
|
|
@ -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
|
||||
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
|
@ -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…
Reference in New Issue