mirror of
https://github.com/logos-messaging/OpChan.git
synced 2026-01-02 21:03:09 +00:00
chore: cleanup lib/forum
This commit is contained in:
parent
88012154d3
commit
62d6800f0b
@ -1,8 +1,7 @@
|
||||
import { RelevanceCalculator } from './relevance';
|
||||
import { Post, Comment, Cell, User } from '@/types';
|
||||
import { RelevanceCalculator } from '../relevance';
|
||||
import { Post, Comment, User, UserVerificationStatus } from '@/types/forum';
|
||||
import { VoteMessage, MessageType } from '@/lib/waku/types';
|
||||
import { expect, describe, beforeEach, it } from 'vitest';
|
||||
import { UserVerificationStatus } from './types';
|
||||
|
||||
describe('RelevanceCalculator', () => {
|
||||
let calculator: RelevanceCalculator;
|
||||
@ -7,7 +7,7 @@ import {
|
||||
VoteMessage,
|
||||
ModerateMessage,
|
||||
} from '@/lib/waku/types';
|
||||
import { Cell, Comment, Post, User } from '@/types';
|
||||
import { Cell, Comment, Post, User } from '@/types/forum';
|
||||
import { transformCell, transformComment, transformPost } from './transformers';
|
||||
import { MessageService } from '@/lib/identity/services/MessageService';
|
||||
import { AuthService } from '@/lib/identity/services/AuthService';
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { Post, Comment, Cell, User } from '@/types';
|
||||
import { Post, Comment, Cell, User, RelevanceScoreDetails, UserVerificationStatus } from '@/types/forum';
|
||||
import { VoteMessage } from '@/lib/waku/types';
|
||||
import { RelevanceScoreDetails, UserVerificationStatus } from './types';
|
||||
|
||||
export class RelevanceCalculator {
|
||||
private static readonly BASE_SCORES = {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Post, Comment, Cell } from '@/types';
|
||||
import { Post, Comment, Cell } from '@/types/forum';
|
||||
|
||||
export type SortOption = 'relevance' | 'time';
|
||||
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
export interface RelevanceScoreDetails {
|
||||
baseScore: number;
|
||||
engagementScore: number;
|
||||
authorVerificationBonus: number;
|
||||
verifiedUpvoteBonus: number;
|
||||
verifiedCommenterBonus: number;
|
||||
timeDecayMultiplier: number;
|
||||
moderationPenalty: number;
|
||||
finalScore: number;
|
||||
isVerified: boolean;
|
||||
upvotes: number;
|
||||
comments: number;
|
||||
verifiedUpvotes: number;
|
||||
verifiedCommenters: number;
|
||||
daysOld: number;
|
||||
isModerated: boolean;
|
||||
}
|
||||
|
||||
export interface UserVerificationStatus {
|
||||
[address: string]: {
|
||||
isVerified: boolean;
|
||||
hasENS: boolean;
|
||||
hasOrdinal: boolean;
|
||||
ensName?: string;
|
||||
verificationStatus?: 'unverified' | 'verified-none' | 'verified-basic' | 'verified-owner' | 'verifying';
|
||||
};
|
||||
}
|
||||
110
src/types/forum.ts
Normal file
110
src/types/forum.ts
Normal file
@ -0,0 +1,110 @@
|
||||
import { CellMessage, CommentMessage, PostMessage, VoteMessage, ModerateMessage } from "@/lib/waku/types";
|
||||
|
||||
export type OpchanMessage = CellMessage | PostMessage | CommentMessage | VoteMessage | ModerateMessage;
|
||||
|
||||
export interface User {
|
||||
address: string;
|
||||
walletType: 'bitcoin' | 'ethereum';
|
||||
|
||||
// Bitcoin-specific
|
||||
ordinalOwnership?: boolean | { id: string; details: string };
|
||||
|
||||
// Ethereum-specific
|
||||
ensName?: string;
|
||||
ensAvatar?: string;
|
||||
ensOwnership?: boolean;
|
||||
|
||||
verificationStatus: 'unverified' | 'verified-none' | 'verified-basic' | 'verified-owner' | 'verifying';
|
||||
|
||||
signature?: string;
|
||||
lastChecked?: number;
|
||||
browserPubKey?: string; // Browser-generated public key for key delegation
|
||||
delegationSignature?: string; // Signature from Bitcoin/Ethereum wallet for delegation
|
||||
delegationExpiry?: number; // When the delegation expires
|
||||
}
|
||||
|
||||
export interface Cell {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
icon?: string;
|
||||
signature?: string; // Message signature
|
||||
browserPubKey?: string; // Public key that signed the message
|
||||
relevanceScore?: number; // Calculated relevance score
|
||||
activeMemberCount?: number; // Number of active members in the cell
|
||||
relevanceDetails?: RelevanceScoreDetails; // Detailed breakdown of relevance score calculation
|
||||
}
|
||||
|
||||
export interface Post {
|
||||
id: string;
|
||||
cellId: string;
|
||||
authorAddress: string;
|
||||
title: string;
|
||||
content: string;
|
||||
timestamp: number;
|
||||
upvotes: VoteMessage[];
|
||||
downvotes: VoteMessage[];
|
||||
signature?: string; // Message signature
|
||||
browserPubKey?: string; // Public key that signed the message
|
||||
moderated?: boolean;
|
||||
moderatedBy?: string;
|
||||
moderationReason?: string;
|
||||
moderationTimestamp?: number;
|
||||
relevanceScore?: number; // Calculated relevance score
|
||||
verifiedUpvotes?: number; // Count of upvotes from verified users
|
||||
verifiedCommenters?: string[]; // List of verified users who commented
|
||||
relevanceDetails?: RelevanceScoreDetails; // Detailed breakdown of relevance score calculation
|
||||
}
|
||||
|
||||
export interface Comment {
|
||||
id: string;
|
||||
postId: string;
|
||||
authorAddress: string;
|
||||
content: string;
|
||||
timestamp: number;
|
||||
upvotes: VoteMessage[];
|
||||
downvotes: VoteMessage[];
|
||||
signature?: string; // Message signature
|
||||
browserPubKey?: string; // Public key that signed the message
|
||||
moderated?: boolean;
|
||||
moderatedBy?: string;
|
||||
moderationReason?: string;
|
||||
moderationTimestamp?: number;
|
||||
relevanceScore?: number; // Calculated relevance score
|
||||
relevanceDetails?: RelevanceScoreDetails; // Detailed breakdown of relevance score calculation
|
||||
}
|
||||
|
||||
// Extended message types for verification
|
||||
export interface SignedMessage {
|
||||
signature?: string; // Signature of the message
|
||||
browserPubKey?: string; // Public key that signed the message
|
||||
}
|
||||
|
||||
|
||||
export interface RelevanceScoreDetails {
|
||||
baseScore: number;
|
||||
engagementScore: number;
|
||||
authorVerificationBonus: number;
|
||||
verifiedUpvoteBonus: number;
|
||||
verifiedCommenterBonus: number;
|
||||
timeDecayMultiplier: number;
|
||||
moderationPenalty: number;
|
||||
finalScore: number;
|
||||
isVerified: boolean;
|
||||
upvotes: number;
|
||||
comments: number;
|
||||
verifiedUpvotes: number;
|
||||
verifiedCommenters: number;
|
||||
daysOld: number;
|
||||
isModerated: boolean;
|
||||
}
|
||||
|
||||
export interface UserVerificationStatus {
|
||||
[address: string]: {
|
||||
isVerified: boolean;
|
||||
hasENS: boolean;
|
||||
hasOrdinal: boolean;
|
||||
ensName?: string;
|
||||
verificationStatus?: 'unverified' | 'verified-none' | 'verified-basic' | 'verified-owner' | 'verifying';
|
||||
};
|
||||
}
|
||||
4
src/types/global.d.ts
vendored
4
src/types/global.d.ts
vendored
@ -1,4 +0,0 @@
|
||||
import 'react';
|
||||
|
||||
// Ensures file is treated as a module
|
||||
export {};
|
||||
@ -1,82 +1 @@
|
||||
import { CellMessage, CommentMessage, PostMessage, VoteMessage, ModerateMessage } from "@/lib/waku/types";
|
||||
import { RelevanceScoreDetails } from "@/lib/forum/relevance";
|
||||
|
||||
export type OpchanMessage = CellMessage | PostMessage | CommentMessage | VoteMessage | ModerateMessage;
|
||||
|
||||
export interface User {
|
||||
address: string;
|
||||
walletType: 'bitcoin' | 'ethereum';
|
||||
|
||||
// Bitcoin-specific
|
||||
ordinalOwnership?: boolean | { id: string; details: string };
|
||||
|
||||
// Ethereum-specific
|
||||
ensName?: string;
|
||||
ensAvatar?: string;
|
||||
ensOwnership?: boolean;
|
||||
|
||||
verificationStatus: 'unverified' | 'verified-none' | 'verified-basic' | 'verified-owner' | 'verifying';
|
||||
|
||||
signature?: string;
|
||||
lastChecked?: number;
|
||||
browserPubKey?: string; // Browser-generated public key for key delegation
|
||||
delegationSignature?: string; // Signature from Bitcoin/Ethereum wallet for delegation
|
||||
delegationExpiry?: number; // When the delegation expires
|
||||
}
|
||||
|
||||
export interface Cell {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
icon?: string;
|
||||
signature?: string; // Message signature
|
||||
browserPubKey?: string; // Public key that signed the message
|
||||
relevanceScore?: number; // Calculated relevance score
|
||||
activeMemberCount?: number; // Number of active members in the cell
|
||||
relevanceDetails?: RelevanceScoreDetails; // Detailed breakdown of relevance score calculation
|
||||
}
|
||||
|
||||
export interface Post {
|
||||
id: string;
|
||||
cellId: string;
|
||||
authorAddress: string;
|
||||
title: string;
|
||||
content: string;
|
||||
timestamp: number;
|
||||
upvotes: VoteMessage[];
|
||||
downvotes: VoteMessage[];
|
||||
signature?: string; // Message signature
|
||||
browserPubKey?: string; // Public key that signed the message
|
||||
moderated?: boolean;
|
||||
moderatedBy?: string;
|
||||
moderationReason?: string;
|
||||
moderationTimestamp?: number;
|
||||
relevanceScore?: number; // Calculated relevance score
|
||||
verifiedUpvotes?: number; // Count of upvotes from verified users
|
||||
verifiedCommenters?: string[]; // List of verified users who commented
|
||||
relevanceDetails?: RelevanceScoreDetails; // Detailed breakdown of relevance score calculation
|
||||
}
|
||||
|
||||
export interface Comment {
|
||||
id: string;
|
||||
postId: string;
|
||||
authorAddress: string;
|
||||
content: string;
|
||||
timestamp: number;
|
||||
upvotes: VoteMessage[];
|
||||
downvotes: VoteMessage[];
|
||||
signature?: string; // Message signature
|
||||
browserPubKey?: string; // Public key that signed the message
|
||||
moderated?: boolean;
|
||||
moderatedBy?: string;
|
||||
moderationReason?: string;
|
||||
moderationTimestamp?: number;
|
||||
relevanceScore?: number; // Calculated relevance score
|
||||
relevanceDetails?: RelevanceScoreDetails; // Detailed breakdown of relevance score calculation
|
||||
}
|
||||
|
||||
// Extended message types for verification
|
||||
export interface SignedMessage {
|
||||
signature?: string; // Signature of the message
|
||||
browserPubKey?: string; // Public key that signed the message
|
||||
}
|
||||
export * as forum from './forum';
|
||||
Loading…
x
Reference in New Issue
Block a user