Move feed utils to its own file

This commit is contained in:
Jon Staab
2024-05-03 10:30:50 -07:00
parent a343f74241
commit d4cf63e906
10 changed files with 245 additions and 143 deletions
+1
View File
@@ -72,6 +72,7 @@ export const USER_STATUSES = 30315
export const CLASSIFIED_LISTING = 30402
export const DRAFT_CLASSIFIED_LISTING = 30403
export const AUDIO = 31337
export const FEED = 31890
export const CALENDAR = 31924
export const CALENDAR_EVENT_DATE = 31922
export const CALENDAR_EVENT_TIME = 31923
+18 -7
View File
@@ -44,14 +44,15 @@ export class Relay<E extends Rumor> extends Emitter {
}
}
_onEVENT([json]: [string]) {
let event: E
try {
event = JSON.parse(json)
} catch (e) {
return
}
has(id: string) {
return this.eventsById.has(id)
}
get(id: string) {
return this.eventsById.get(id)
}
put(event: E) {
const duplicateById = this.eventsById.get(event.id)
if (duplicateById) {
@@ -67,7 +68,17 @@ export class Relay<E extends Rumor> extends Emitter {
}
this._addEvent(event, duplicateByAddress)
}
_onEVENT([json]: [string]) {
let event: E
try {
event = JSON.parse(json)
} catch (e) {
return
}
this.put(event)
this.emit('OK', event.id, true, "")
if (!this._isDeleted(event)) {