MCPcopy Create free account
hub / github.com/cameri/nostream / eventStrategyFactory

Function eventStrategyFactory

src/factories/event-strategy-factory.ts:28–52  ·  view source on GitHub ↗
(
    eventRepository: IEventRepository,
    userRepository: IUserRepository,
  )

Source from the content-addressed store, hash-verified

26
27export const eventStrategyFactory =
28 (
29 eventRepository: IEventRepository,
30 userRepository: IUserRepository,
31 ): Factory<IEventStrategy<Event, Promise<void>>, [Event, IWebSocketAdapter]> =>
32 ([event, adapter]: [Event, IWebSocketAdapter]) => {
33 if (isRequestToVanishEvent(event)) {
34 return new VanishEventStrategy(adapter, eventRepository, userRepository)
35 } else if (isGiftWrapEvent(event)) {
36 return new GiftWrapEventStrategy(adapter, eventRepository)
37 } else if (isMarmotGroupEvent(event)) {
38 return new GroupEventStrategy(adapter, eventRepository)
39 } else if (isOpenTimestampsEvent(event)) {
40 return new TimestampEventStrategy(adapter, eventRepository)
41 } else if (isRelayListEvent(event) || isReplaceableEvent(event)) {
42 return new ReplaceableEventStrategy(adapter, eventRepository)
43 } else if (isEphemeralEvent(event)) {
44 return new EphemeralEventStrategy(adapter)
45 } else if (isDeleteEvent(event)) {
46 return new DeleteEventStrategy(adapter, eventRepository)
47 } else if (isParameterizedReplaceableEvent(event)) {
48 return new ParameterizedReplaceableEventStrategy(adapter, eventRepository)
49 }
50
51 return new DefaultEventStrategy(adapter, eventRepository)
52 }

Callers 2

messageHandlerFactoryFunction · 0.90

Calls 9

isRequestToVanishEventFunction · 0.90
isGiftWrapEventFunction · 0.90
isMarmotGroupEventFunction · 0.90
isOpenTimestampsEventFunction · 0.90
isRelayListEventFunction · 0.90
isReplaceableEventFunction · 0.90
isEphemeralEventFunction · 0.90
isDeleteEventFunction · 0.90

Tested by

no test coverage detected