mirror of
https://github.com/wassname/talk.git
synced 2026-08-01 13:00:55 +08:00
feat: signup enhancements; more extensions to schema
This commit is contained in:
@@ -3,7 +3,10 @@ import { Db } from "mongodb";
|
||||
import uuid from "uuid";
|
||||
|
||||
import { Omit, Sub } from "talk-common/types";
|
||||
import { GQLCOMMENT_SORT } from "talk-server/graph/tenant/schema/__generated__/types";
|
||||
import {
|
||||
GQLCOMMENT_SORT,
|
||||
GQLCOMMENT_STATUS,
|
||||
} from "talk-server/graph/tenant/schema/__generated__/types";
|
||||
import { ActionCounts } from "talk-server/models/actions";
|
||||
import { Connection, Cursor } from "talk-server/models/connection";
|
||||
import Query from "talk-server/models/query";
|
||||
@@ -19,19 +22,11 @@ export interface BodyHistoryItem {
|
||||
}
|
||||
|
||||
export interface StatusHistoryItem {
|
||||
status: CommentStatus; // TODO: migrate field
|
||||
status: GQLCOMMENT_STATUS; // TODO: migrate field
|
||||
assigned_by?: string;
|
||||
created_at: Date;
|
||||
}
|
||||
|
||||
export enum CommentStatus {
|
||||
ACCEPTED = "ACCEPTED",
|
||||
REJECTED = "REJECTED",
|
||||
PREMOD = "PREMOD",
|
||||
SYSTEM_WITHHELD = "SYSTEM_WITHHELD",
|
||||
NONE = "NONE",
|
||||
}
|
||||
|
||||
export interface Comment extends TenantResource {
|
||||
readonly id: string;
|
||||
parent_id: string | null;
|
||||
@@ -39,7 +34,7 @@ export interface Comment extends TenantResource {
|
||||
asset_id: string;
|
||||
body: string;
|
||||
body_history: BodyHistoryItem[];
|
||||
status: CommentStatus;
|
||||
status: GQLCOMMENT_STATUS;
|
||||
status_history: StatusHistoryItem[];
|
||||
action_counts: ActionCounts;
|
||||
reply_count: number;
|
||||
|
||||
@@ -4,7 +4,10 @@ import { Db } from "mongodb";
|
||||
import uuid from "uuid";
|
||||
|
||||
import { Sub } from "talk-common/types";
|
||||
import { GQLUSER_ROLE } from "talk-server/graph/tenant/schema/__generated__/types";
|
||||
import {
|
||||
GQLMODERATION_MODE,
|
||||
GQLUSER_ROLE,
|
||||
} from "talk-server/graph/tenant/schema/__generated__/types";
|
||||
|
||||
function collection(db: Db) {
|
||||
return db.collection<Readonly<Tenant>>("tenants");
|
||||
@@ -19,11 +22,6 @@ export interface Wordlist {
|
||||
suspect: string[];
|
||||
}
|
||||
|
||||
export enum Moderation {
|
||||
PRE = "PRE",
|
||||
POST = "POST",
|
||||
}
|
||||
|
||||
// AuthIntegrations.
|
||||
|
||||
export interface EmailDomainRuleCondition {
|
||||
@@ -90,8 +88,8 @@ export interface GoogleAuthIntegration extends AuthIntegration {
|
||||
|
||||
export type LocalAuthIntegration = AuthIntegration;
|
||||
|
||||
// Auth describes all of the possible auth integration configurations.
|
||||
export interface Auth {
|
||||
// AuthIntegrations describes all of the possible auth integration configurations.
|
||||
export interface AuthIntegrations {
|
||||
// local is the auth integration for the local auth.
|
||||
local: LocalAuthIntegration;
|
||||
|
||||
@@ -108,6 +106,11 @@ export interface Auth {
|
||||
facebook?: FacebookAuthIntegration;
|
||||
}
|
||||
|
||||
export interface Auth {
|
||||
integrations: AuthIntegrations;
|
||||
displayNameEnable: boolean;
|
||||
}
|
||||
|
||||
// Tenant definition.
|
||||
|
||||
export interface Tenant {
|
||||
@@ -117,7 +120,7 @@ export interface Tenant {
|
||||
// specific tenant that the API request pertains to.
|
||||
domain: string;
|
||||
|
||||
moderation: Moderation;
|
||||
moderation: GQLMODERATION_MODE;
|
||||
requireEmailConfirmation: boolean;
|
||||
infoBoxEnable: boolean;
|
||||
infoBoxContent?: string;
|
||||
@@ -172,7 +175,7 @@ export async function createTenant(db: Db, input: CreateTenantInput) {
|
||||
id: uuid.v4(),
|
||||
|
||||
// Default to post moderation.
|
||||
moderation: Moderation.POST,
|
||||
moderation: GQLMODERATION_MODE.POST,
|
||||
|
||||
// Email confirmation is default off.
|
||||
requireEmailConfirmation: false,
|
||||
@@ -191,8 +194,12 @@ export async function createTenant(db: Db, input: CreateTenantInput) {
|
||||
banned: [],
|
||||
},
|
||||
auth: {
|
||||
local: {
|
||||
enabled: true,
|
||||
// Disable the displayName by default.
|
||||
displayNameEnable: false,
|
||||
integrations: {
|
||||
local: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -15,12 +15,24 @@ function collection(db: Db) {
|
||||
return db.collection<Readonly<User>>("users");
|
||||
}
|
||||
|
||||
export interface Profile {
|
||||
readonly id: string;
|
||||
readonly type: string;
|
||||
provider?: string;
|
||||
export interface LocalProfile {
|
||||
type: "local";
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface OIDCProfile {
|
||||
type: "oidc";
|
||||
id: string;
|
||||
provider: string;
|
||||
}
|
||||
|
||||
export interface SSOProfile {
|
||||
type: "sso";
|
||||
id: string;
|
||||
}
|
||||
|
||||
export type Profile = LocalProfile | OIDCProfile | SSOProfile;
|
||||
|
||||
export interface Token {
|
||||
readonly id: string;
|
||||
name: string;
|
||||
@@ -28,14 +40,14 @@ export interface Token {
|
||||
}
|
||||
|
||||
export interface UserStatusHistory<T> {
|
||||
status: T; // TODO: migrate field
|
||||
status: T;
|
||||
assigned_by?: string;
|
||||
reason?: string; // TODO: migrate field
|
||||
reason?: string;
|
||||
created_at: Date;
|
||||
}
|
||||
|
||||
export interface UserStatusItem<T> {
|
||||
status: T; // TODO: migrate field
|
||||
status: T;
|
||||
history: Array<UserStatusHistory<T>>;
|
||||
}
|
||||
|
||||
@@ -48,6 +60,7 @@ export interface UserStatus {
|
||||
export interface User extends TenantResource {
|
||||
readonly id: string;
|
||||
username: string | null;
|
||||
displayName?: string;
|
||||
password?: string;
|
||||
email?: string;
|
||||
email_verified?: boolean;
|
||||
@@ -56,7 +69,7 @@ export interface User extends TenantResource {
|
||||
role: GQLUSER_ROLE;
|
||||
status: UserStatus;
|
||||
action_counts: ActionCounts;
|
||||
ignored_users: string[]; // TODO: migrate field
|
||||
ignored_users: string[];
|
||||
created_at: Date;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user