A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
feat(api): add dispute, ACL, SSO and community visit tables
Hampus230d5df9c964
diff --git a/fluxer_api/src/api/Tables.ts b/fluxer_api/src/api/Tables.tsindex 23e306118..af1739bf1 100644--- a/fluxer_api/src/api/Tables.ts+++ b/fluxer_api/src/api/Tables.ts@@ -175,6 +175,7 @@ import {type GuildRow,type GuildStickerRow,} from '@app/api/database/types/GuildTypes';+import {GUILD_VISIT_COLUMNS, type GuildVisitRow} from '@app/api/database/types/GuildVisitTypes';import {INSTANCE_CONFIGURATION_COLUMNS,type InstanceConfigurationRow,@@ -218,6 +219,12 @@ import {type OAuth2RefreshTokenByUserRow,type OAuth2RefreshTokenRow,} from '@app/api/database/types/OAuth2Types';+import {+ PAYMENT_DISPUTE_REVIEW_BY_PURCHASER_COLUMNS,+ PAYMENT_DISPUTE_REVIEW_COLUMNS,+ type PaymentDisputeReviewByPurchaserRow,+ type PaymentDisputeReviewRow,+} from '@app/api/database/types/PaymentDisputeTypes';import {GIFT_CODE_BY_CREATOR_COLUMNS,GIFT_CODE_BY_PAYMENT_INTENT_COLUMNS,@@ -301,6 +308,7 @@ import {type RelationshipRow,SAVED_MESSAGE_COLUMNS,type SavedMessageRow,+ USER_BY_ACL_COLUMNS,USER_BY_EMAIL_COLUMNS,USER_BY_LAST_ACTIVE_IP_COLUMNS,USER_BY_LAST_ACTIVE_IP_TRUST_KEY_COLUMNS,@@ -316,6 +324,7 @@ import {USER_GUILD_SETTINGS_COLUMNS,USER_HARVEST_COLUMNS,USER_SETTINGS_COLUMNS,+ type UserByAclRow,type UserByEmailRow,type UserByLastActiveIpRow,type UserByLastActiveIpTrustKeyRow,@@ -337,6 +346,7 @@ import {type VoiceP2pConnectionReportRow,} from '@app/api/database/types/VoiceTypes';import {ATTACHMENT_DECAY_COLUMNS, type AttachmentDecayRow} from '@app/api/types/AttachmentDecayTypes';+import {GUILD_VISIT_TTL_SECONDS} from '@fluxer/constants/src/GuildVisitConstants';import {seconds} from 'itty-time';export const Users = defineTable<UserRow, 'user_id'>({@@ -371,6 +381,22 @@ export const UserSsoIdentities = defineTable<UserSsoIdentityRow, 'provider_id' |primaryKey: ['provider_id', 'subject'],partitionKey: ['provider_id'],});+export const UserSsoIdentitiesByUser = defineTable<+ UserSsoIdentityRow,+ 'user_id' | 'provider_id' | 'subject',+ 'user_id'+>({+ name: 'user_sso_identities_by_user',+ columns: USER_SSO_IDENTITY_COLUMNS,+ primaryKey: ['user_id', 'provider_id', 'subject'],+ partitionKey: ['user_id'],+});+export const UserByAcl = defineTable<UserByAclRow, 'acl' | 'user_id', 'acl'>({+ name: 'users_by_acl',+ columns: USER_BY_ACL_COLUMNS,+ primaryKey: ['acl', 'user_id'],+ partitionKey: ['acl'],+});export const UserByStripeCustomerId = defineTable<UserByStripeCustomerIdRow, 'stripe_customer_id' | 'user_id'>({name: 'users_by_stripe_customer_id',columns: USER_BY_STRIPE_CUSTOMER_ID_COLUMNS,@@ -485,6 +511,20 @@ export const GuildBansByUserId = defineTable<GuildBanByUserIdRow, 'user_id' | 'gprimaryKey: ['user_id', 'guild_id'],partitionKey: ['user_id'],});+export const GuildVisitsByUser = defineTable<GuildVisitRow, 'user_id' | 'guild_id', 'user_id'>({+ name: 'guild_visits_by_user',+ columns: GUILD_VISIT_COLUMNS,+ primaryKey: ['user_id', 'guild_id'],+ partitionKey: ['user_id'],+ defaultTtlSeconds: GUILD_VISIT_TTL_SECONDS,+});+export const GuildVisitsByGuild = defineTable<GuildVisitRow, 'guild_id' | 'user_id', 'guild_id'>({+ name: 'guild_visits_by_guild',+ columns: GUILD_VISIT_COLUMNS,+ primaryKey: ['guild_id', 'user_id'],+ partitionKey: ['guild_id'],+ defaultTtlSeconds: GUILD_VISIT_TTL_SECONDS,+});export const GuildAuditLogs = defineTable<GuildAuditLogRow, 'guild_id' | 'log_id'>({name: 'guild_audit_logs_v2',columns: GUILD_AUDIT_LOG_COLUMNS,@@ -1444,6 +1484,21 @@ export const BillingRefundsByInvoice = defineTable<primaryKey: ['invoice_id', 'stripe_created_at', 'provider_id'],partitionKey: ['invoice_id'],});+export const PaymentDisputeReviews = defineTable<PaymentDisputeReviewRow, 'dispute_id'>({+ name: 'payment_dispute_reviews',+ columns: PAYMENT_DISPUTE_REVIEW_COLUMNS,+ primaryKey: ['dispute_id'],+});+export const PaymentDisputeReviewsByPurchaser = defineTable<+ PaymentDisputeReviewByPurchaserRow,+ 'purchaser_id' | 'dispute_id',+ 'purchaser_id'+>({+ name: 'payment_dispute_reviews_by_purchaser',+ columns: PAYMENT_DISPUTE_REVIEW_BY_PURCHASER_COLUMNS,+ primaryKey: ['purchaser_id', 'dispute_id'],+ partitionKey: ['purchaser_id'],+});export const VoiceP2pConnectionReports = defineTable<VoiceP2pConnectionReportRow, 'user_id' | 'report_id'>({name: 'voice_p2p_connection_reports',columns: VOICE_P2P_CONNECTION_REPORT_COLUMNS,diff --git a/fluxer_api/src/api/database/types/PaymentDisputeTypes.ts b/fluxer_api/src/api/database/types/PaymentDisputeTypes.tsnew file mode 100644index 000000000..6f3355ef2--- /dev/null+++ b/fluxer_api/src/api/database/types/PaymentDisputeTypes.ts@@ -0,0 +1,99 @@+// SPDX-License-Identifier: AGPL-3.0-or-later++import type {UserID} from '@app/api/BrandedTypes';++type Nullish<T> = T | null;++export type PaymentDisputeProduct = 'operator_pass' | 'plutonium';++type PaymentDisputeReviewStatus = 'open' | 'justified' | 'unjustified';++export interface PaymentDisputeReviewRow {+ dispute_id: string;+ product: PaymentDisputeProduct;+ order_id: string;+ invoice_number: Nullish<string>;+ purchaser_id: UserID;+ is_gift: boolean;+ reason: string;+ payment_intent_id: Nullish<string>;+ charge_id: Nullish<string>;+ amount_minor: number;+ currency: string;+ evidence_submitted: boolean;+ evidence_due_by: Nullish<Date>;+ disputed_at: Nullish<Date>;+ closed_at: Nullish<Date>;+ outcome: Nullish<string>;+ purchased_at: Nullish<Date>;+ perks_started_at: Nullish<Date>;+ withdrawal_ends_at: Nullish<Date>;+ withdrawn_at: Nullish<Date>;+ refunded_at: Nullish<Date>;+ perks_removed_at: Nullish<Date>;+ status: PaymentDisputeReviewStatus;+ created_at: Date;+ decided_at: Nullish<Date>;+ decided_by: Nullish<UserID>;+ decision_note: Nullish<string>;+ warning_deadline: Nullish<Date>;+ warned_at: Nullish<Date>;+ warning_email_sent_at: Nullish<Date>;+ warning_dm_sent_at: Nullish<Date>;+ enforcement_decision_id: Nullish<bigint>;+ reversed_at: Nullish<Date>;+ reversed_by: Nullish<UserID>;+ reversal_note: Nullish<string>;+ dispute_purchase_at: Nullish<Date>;+ version: number;+}++export interface PaymentDisputeReviewByPurchaserRow {+ purchaser_id: UserID;+ dispute_id: string;+}++export const PAYMENT_DISPUTE_REVIEW_COLUMNS = [+ 'dispute_id',+ 'product',+ 'order_id',+ 'invoice_number',+ 'purchaser_id',+ 'is_gift',+ 'reason',+ 'payment_intent_id',+ 'charge_id',+ 'amount_minor',+ 'currency',+ 'evidence_submitted',+ 'evidence_due_by',+ 'disputed_at',+ 'closed_at',+ 'outcome',+ 'purchased_at',+ 'perks_started_at',+ 'withdrawal_ends_at',+ 'withdrawn_at',+ 'refunded_at',+ 'perks_removed_at',+ 'status',+ 'created_at',+ 'decided_at',+ 'decided_by',+ 'decision_note',+ 'warning_deadline',+ 'warned_at',+ 'warning_email_sent_at',+ 'warning_dm_sent_at',+ 'enforcement_decision_id',+ 'reversed_at',+ 'reversed_by',+ 'reversal_note',+ 'dispute_purchase_at',+ 'version',+] as const satisfies ReadonlyArray<keyof PaymentDisputeReviewRow>;++export const PAYMENT_DISPUTE_REVIEW_BY_PURCHASER_COLUMNS = [+ 'purchaser_id',+ 'dispute_id',+] as const satisfies ReadonlyArray<keyof PaymentDisputeReviewByPurchaserRow>;diff --git a/fluxer_api/src/api/database/types/UserTypes.ts b/fluxer_api/src/api/database/types/UserTypes.tsindex 4ae6d90af..504418a2f 100644--- a/fluxer_api/src/api/database/types/UserTypes.ts+++ b/fluxer_api/src/api/database/types/UserTypes.ts@@ -586,6 +586,11 @@ export interface UserByStripeSubscriptionIdRow {user_id: UserID;}+export interface UserByAclRow {+ acl: string;+ user_id: UserID;+}+export interface UserByLastActiveIpRow {last_active_ip: string;user_id: UserID;@@ -615,6 +620,7 @@ export const USER_BY_STRIPE_SUBSCRIPTION_ID_COLUMNS = ['stripe_subscription_id','user_id',] as const satisfies ReadonlyArray<keyof UserByStripeSubscriptionIdRow>;+export const USER_BY_ACL_COLUMNS = ['acl', 'user_id'] as const satisfies ReadonlyArray<keyof UserByAclRow>;export const USER_BY_LAST_ACTIVE_IP_COLUMNS = ['last_active_ip','user_id',