diff --git a/backend/src/activitypub/actors/index.ts b/backend/src/activitypub/actors/index.ts index 7156827..25f64b1 100644 --- a/backend/src/activitypub/actors/index.ts +++ b/backend/src/activitypub/actors/index.ts @@ -150,7 +150,8 @@ export async function createPerson( db: Database, userKEK: string, email: string, - properties: PersonProperties = {} + properties: PersonProperties = {}, + admin: boolean = false ): Promise { const userKeyPair = await generateUserKey(userKEK) @@ -198,12 +199,12 @@ export async function createPerson( const row = await db .prepare( ` - INSERT INTO actors(id, type, email, pubkey, privkey, privkey_salt, properties) - VALUES(?, ?, ?, ?, ?, ?, ?) + INSERT INTO actors(id, type, email, pubkey, privkey, privkey_salt, properties, is_admin) + VALUES(?, ?, ?, ?, ?, ?, ?, ?) RETURNING * ` ) - .bind(id, PERSON, email, userKeyPair.pubKey, privkey, salt, JSON.stringify(properties)) + .bind(id, PERSON, email, userKeyPair.pubKey, privkey, salt, JSON.stringify(properties), admin ? 1 : null) .first() return personFromRow(row) diff --git a/frontend/mock-db/init.ts b/frontend/mock-db/init.ts index dc97a27..a9cde78 100644 --- a/frontend/mock-db/init.ts +++ b/frontend/mock-db/init.ts @@ -74,12 +74,21 @@ async function getOrCreatePerson( db: Database, { username, avatar, display_name }: Account ): Promise { - const person = await getPersonByEmail(db, username) + const isAdmin = username === 'george' + const email = `${username}@test.email` + const person = await getPersonByEmail(db, email) if (person) return person - const newPerson = await createPerson(domain, db, 'test-kek', username, { - icon: { url: avatar }, - name: display_name, - }) + const newPerson = await createPerson( + domain, + db, + 'test-kek', + email, + { + icon: { url: avatar }, + name: display_name, + }, + isAdmin + ) if (!newPerson) { throw new Error('Could not create Actor ' + username) } diff --git a/frontend/src/components/Settings/TextArea.tsx b/frontend/src/components/Settings/TextArea.tsx new file mode 100644 index 0000000..f83f302 --- /dev/null +++ b/frontend/src/components/Settings/TextArea.tsx @@ -0,0 +1,34 @@ +import { component$, useSignal } from '@builder.io/qwik' + +type Props = { + label: string + name?: string + description?: string + class?: string + invalid?: boolean + value?: string + required?: boolean +} + +export const TextArea = component$( + ({ class: className, label, name, description, invalid, value, required }) => { + const inputId = useSignal(`${label.replace(/\s+/g, '_')}___${crypto.randomUUID()}`).value + return ( +
+ + {!!description &&
{description}
} +