Move feed utils to its own file
This commit is contained in:
@@ -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
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user