Add better handling for first/last name, profile photo, tagline to activitypub implementation
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/promote/production Build is passing

This commit is contained in:
Garrett Mills 2023-11-07 21:12:39 -06:00
parent d4d10af972
commit a6e1819d2d
7 changed files with 358 additions and 289 deletions

View File

@ -9,7 +9,7 @@
},
"dependencies": {
"@atao60/fse-cli": "^0.1.7",
"@extollo/lib": "^0.14.10",
"@extollo/lib": "^0.14.14",
"@types/marked": "^4.0.8",
"@types/node": "^18.11.9",
"@types/xml2js": "^0.4.11",
@ -18,6 +18,7 @@
"feed": "^4.2.2",
"gotify": "^1.1.0",
"gray-matter": "^4.0.3",
"lib": "link:@extollo/lib:../extollo/lib",
"marked": "^4.2.12",
"ts-expose-internals": "^4.5.4",
"ts-node": "^10.9.1",

File diff suppressed because it is too large Load Diff

View File

@ -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
View 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([])
}
}

View File

@ -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)
}
}

View File

@ -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,

View File

@ -19,6 +19,7 @@ export namespace Pub {
type: 'Person',
name: string,
url: string,
summary?: string,
icon?: string,
image?: string,
discoverable: boolean,