Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/api-main/drizzle/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const MEMO_LENGTH = 512;
export const FeedTable = pgTable(
'feed',
{
block_height: bigint({ mode: 'bigint' }), // Height of the block that contains the transaction
hash: varchar({ length: 64 }).primaryKey(), // Main hash from the transaction
post_hash: varchar({ length: 64 }), // Optional, this makes a post a reply, provided through memo
author: varchar({ length: 44 }).notNull(), // Address of user, usually in the transfer message
Expand Down
4 changes: 3 additions & 1 deletion packages/api-main/src/posts/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { postToDiscord } from '../utility';
const statement = getDatabase()
.insert(FeedTable)
.values({
block_height: sql.placeholder('block_height'),
hash: sql.placeholder('hash'),
timestamp: sql.placeholder('timestamp'),
author: sql.placeholder('author'),
Expand All @@ -25,6 +26,7 @@ export async function Post(body: Posts.PostBody) {
}

await statement.execute({
block_height: body.block_height,
hash: body.hash.toLowerCase(),
timestamp: new Date(body.timestamp),
author: body.from.toLowerCase(),
Expand All @@ -50,7 +52,7 @@ async function removePostIfBanned(body: Posts.PostBody) {
.where(eq(AuditTable.user_address, body.from))
.orderBy(desc(AuditTable.created_at))
.limit(1);
// If there are not action over the user of they were restored (unbanned), do nothing
// If there are not action over the user of they were restored (unbanned), do nothing
if (!lastAuditOnUser || lastAuditOnUser.restored_at) {
return;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/feed-sync/src/feed/replication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export class FeedReplicationService {
await this.publish(lsn, post, publishRetries);
logger.info('Post published', {
lsn,
height: post.block_height,
hash: post.hash,
timestamp: post.timestamp,
});
Expand Down Expand Up @@ -186,6 +187,7 @@ export class FeedReplicationService {
logger.warn('Post publish failed', {
attempt,
hash: post.hash,
height: post.block_height,
cause: (e as Error).message,
});
}
Expand Down
4 changes: 2 additions & 2 deletions packages/feed-sync/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export async function main() {
const res = await client.query(query);

for (const post of res.rows) {
const { hash, timestamp } = post;
logger.debug('Replaying post', { hash, timestamp });
const { block_height, hash, timestamp } = post;
logger.debug('Replaying post', { block_height, hash, timestamp });
await publisher.publish(post);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/lib-api-types/src/posts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const ModBanBodySchema = t.Object({
export type ModBanBody = Static<typeof ModBanBodySchema>;

export const PostBodySchema = t.Object({
block_height: t.String(),
hash: t.String(),
timestamp: t.String(),
from: t.String(),
Expand Down
1 change: 1 addition & 0 deletions packages/reader-main/src/messages/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export async function Post(action: ActionWithData): Promise<ResponseStatus> {
try {
const [message] = extractMemoContent(action.memo, 'dither.Post');
const postBody: Posts.PostBody = {
block_height: action.height,
hash: action.hash,
from: action.sender,
msg: message,
Expand Down
Loading