Skip to content

Commit

Permalink
removed telegrambot
Browse files Browse the repository at this point in the history
  • Loading branch information
silkroadnomad committed Dec 21, 2024
1 parent 59ff67b commit 9d838a0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion relay/src/pubsubHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import logger from './logger.js';
import { getLastNameOps } from "./pinner/nameOpsFileManager.js";
import { formatFileSize } from './utils.js';
import moment from 'moment';
import CID from 'cids';

export function setupPubsub(helia, orbitdb, pinningService, electrumClient, fsHelia, CONTENT_TOPIC) {
helia.libp2p.services.pubsub.subscribe(CONTENT_TOPIC);
Expand Down Expand Up @@ -138,6 +139,15 @@ async function processNewCID(cid, fsHelia, pinningService, electrumClient, helia
let imageSize = 0;
if (metadata.image && metadata.image.startsWith('ipfs://')) {
const imageCid = metadata.image.replace('ipfs://', '');

// Validate the CID format
try {
CID.parse(imageCid); // Ensure the CID is valid
} catch (cidError) {
logger.error(`Invalid CID format for image: ${imageCid}`, cidError);
throw new Error(`Invalid CID format for image: ${imageCid}`);
}

logger.info(`Found image in metadata, fetching size for CID: ${imageCid}`);
try {
for await (const chunk of fsHelia.cat(imageCid)) {
Expand Down Expand Up @@ -191,7 +201,6 @@ async function processNewCID(cid, fsHelia, pinningService, electrumClient, helia

} catch (error) {
logger.error('Error processing file or sending notification:', error);
await telegramBot.sendMessage(`⚠️ Error processing new file with CID: ${cid}\nError: ${error.message}`);
}

const addedMsg = JSON.stringify({
Expand Down

0 comments on commit 9d838a0

Please sign in to comment.