Add better handling for first/last name, profile photo, tagline to activitypub implementation
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
||||
} from '@extollo/lib'
|
||||
import {AppUnit} from './app/AppUnit'
|
||||
import {CobaltUnit} from './app/services/CobaltUnit'
|
||||
import {MigrateUnit} from './app/MigrateUnit'
|
||||
|
||||
Error.stackTraceLimit = 500
|
||||
|
||||
@@ -39,6 +40,7 @@ export const Units = [
|
||||
Internationalization,
|
||||
Authentication,
|
||||
|
||||
MigrateUnit,
|
||||
AppUnit,
|
||||
|
||||
Routing,
|
||||
|
||||
13
src/app/MigrateUnit.ts
Normal file
13
src/app/MigrateUnit.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import {Unit, Singleton, MigrateDirective} from '@extollo/lib'
|
||||
|
||||
/**
|
||||
* Apply migrations when the application starts up.
|
||||
* This is way more convenient than `./ex migrate` for Kubernetes deployments.
|
||||
*/
|
||||
@Singleton()
|
||||
export class MigrateUnit extends Unit {
|
||||
async up() {
|
||||
const directive = this.make<MigrateDirective>(MigrateDirective)
|
||||
await directive.invoke([])
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import {Injectable, Migration, Inject, DatabaseService, FieldType} from '@extollo/lib'
|
||||
|
||||
/**
|
||||
* AddCoreidColumnsToUsersTableMigration
|
||||
* ----------------------------------
|
||||
* Put some description here.
|
||||
*/
|
||||
@Injectable()
|
||||
export default class AddCoreidColumnsToUsersTableMigration extends Migration {
|
||||
@Inject()
|
||||
protected readonly db!: DatabaseService
|
||||
|
||||
/**
|
||||
* Apply the migration.
|
||||
*/
|
||||
async up(): Promise<void> {
|
||||
const schema = this.db.get().schema()
|
||||
const table = await schema.table('users')
|
||||
|
||||
table.column('tagline')
|
||||
.type(FieldType.varchar)
|
||||
.nullable()
|
||||
|
||||
table.column('photo_url')
|
||||
.type(FieldType.varchar)
|
||||
.nullable()
|
||||
|
||||
await schema.commit(table)
|
||||
}
|
||||
|
||||
/**
|
||||
* Undo the migration.
|
||||
*/
|
||||
async down(): Promise<void> {
|
||||
const schema = this.db.get().schema()
|
||||
const table = await schema.table('users')
|
||||
|
||||
table.dropColumn('tagline')
|
||||
table.dropColumn('photo_url')
|
||||
|
||||
await schema.commit(table)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Inject, Injectable, Maybe, ModelBuilder, ORMUser, Related, Routing} from '@extollo/lib'
|
||||
import {Inject, Injectable, Maybe, Field, ORMUser, FieldType, Routing} from '@extollo/lib'
|
||||
import {Pub} from '../../pub/types'
|
||||
import {Certificate} from './pub/Certificate.model'
|
||||
import * as child_process from 'child_process'
|
||||
@@ -8,6 +8,12 @@ export class User extends ORMUser {
|
||||
@Inject()
|
||||
protected readonly routing!: Routing
|
||||
|
||||
@Field(FieldType.varchar)
|
||||
public tagline?: string
|
||||
|
||||
@Field(FieldType.varchar, 'photo_url')
|
||||
public photoUrl?: string
|
||||
|
||||
get pubUrl(): string {
|
||||
return `${this.routing.getAppUrl().toRemote}/pub/${this.username}`
|
||||
}
|
||||
@@ -45,7 +51,8 @@ export class User extends ORMUser {
|
||||
discoverable: true,
|
||||
indexable: false,
|
||||
published: '2023-11-06T00:00:00.000Z', // FIXME
|
||||
// icon: '', // FIXME
|
||||
...(this.tagline ? {summary: this.tagline} : {}),
|
||||
...(this.photoUrl ? {icon: this.photoUrl} : {}),
|
||||
// image: '', // FIXME
|
||||
preferredUsername: this.username,
|
||||
manuallyApprovesFollowers: false,
|
||||
|
||||
@@ -19,6 +19,7 @@ export namespace Pub {
|
||||
type: 'Person',
|
||||
name: string,
|
||||
url: string,
|
||||
summary?: string,
|
||||
icon?: string,
|
||||
image?: string,
|
||||
discoverable: boolean,
|
||||
|
||||
Reference in New Issue
Block a user