2023-07-25 20:30:58 +00:00
|
|
|
import { Conf } from '@/config.ts';
|
2023-07-25 22:07:09 +00:00
|
|
|
import { relayInit } from '@/deps.ts';
|
|
|
|
import { trends } from '@/trends.ts';
|
|
|
|
import { nostrNow } from '@/utils.ts';
|
2023-07-25 20:30:58 +00:00
|
|
|
|
|
|
|
const relay = relayInit(Conf.relay);
|
|
|
|
await relay.connect();
|
|
|
|
|
2023-07-25 22:07:09 +00:00
|
|
|
const sub = relay.sub([{ kinds: [1], since: nostrNow() }]);
|
2023-07-25 20:30:58 +00:00
|
|
|
|
|
|
|
sub.on('event', (event) => {
|
2023-07-25 22:07:09 +00:00
|
|
|
console.info('loopback event:', event.id);
|
2023-07-25 20:30:58 +00:00
|
|
|
const tags = event.tags
|
|
|
|
.filter((tag) => tag[0] === 't')
|
|
|
|
.map((tag) => tag[1]);
|
|
|
|
|
|
|
|
try {
|
|
|
|
trends.addTagUsages(event.pubkey, tags);
|
|
|
|
} catch (_e) {
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
});
|