mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-02 14:03:06 +00:00
updated libwaku API to integrate with logos chat poc for mix integration
This commit is contained in:
parent
96196ab8bc
commit
dc0ebc7142
@ -47,8 +47,10 @@ proc waku_filter_subscribe(
|
|||||||
error "fail filter subscribe", error = errorMsg
|
error "fail filter subscribe", error = errorMsg
|
||||||
return err(errorMsg)
|
return err(errorMsg)
|
||||||
|
|
||||||
|
let pubsubTopicOpt =
|
||||||
|
if ($pubsubTopic).len > 0: some(PubsubTopic($pubsubTopic)) else: none(PubsubTopic)
|
||||||
let subFut = ctx.myLib[].node.filterSubscribe(
|
let subFut = ctx.myLib[].node.filterSubscribe(
|
||||||
some(PubsubTopic($pubsubTopic)),
|
pubsubTopicOpt,
|
||||||
($contentTopics).split(",").mapIt(ContentTopic(it)),
|
($contentTopics).split(",").mapIt(ContentTopic(it)),
|
||||||
peer,
|
peer,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -39,13 +39,15 @@ proc waku_lightpush_publish(
|
|||||||
let errorMsg = "failed to lightpublish message, no suitable remote peers"
|
let errorMsg = "failed to lightpublish message, no suitable remote peers"
|
||||||
error "PUBLISH failed", error = errorMsg
|
error "PUBLISH failed", error = errorMsg
|
||||||
return err(errorMsg)
|
return err(errorMsg)
|
||||||
|
let topic =
|
||||||
|
if ($pubsubTopic).len == 0:
|
||||||
|
none(PubsubTopic)
|
||||||
|
else:
|
||||||
|
some(PubsubTopic($pubsubTopic))
|
||||||
|
|
||||||
let msgHashHex = (
|
discard (await ctx.myLib[].node.lightpushPublish(topic, msg, peerOpt)).valueOr:
|
||||||
await ctx.myLib[].node.wakuLegacyLightpushClient.publish(
|
let errorMsg = error.desc.get($error.code.int)
|
||||||
$pubsubTopic, msg, peer = peerOpt.get()
|
error "PUBLISH failed", error = errorMsg
|
||||||
)
|
return err(errorMsg)
|
||||||
).valueOr:
|
|
||||||
error "PUBLISH failed", error = error
|
|
||||||
return err($error)
|
|
||||||
|
|
||||||
return ok(msgHashHex)
|
return ok("")
|
||||||
|
|||||||
@ -246,12 +246,16 @@ proc lightpushPublish*(
|
|||||||
return lighpushErrorResult(
|
return lighpushErrorResult(
|
||||||
LightPushErrorCode.SERVICE_NOT_AVAILABLE, "Waku lightpush not available"
|
LightPushErrorCode.SERVICE_NOT_AVAILABLE, "Waku lightpush not available"
|
||||||
)
|
)
|
||||||
if mixify and node.wakuMix.isNil():
|
var lmixify = mixify
|
||||||
error "failed to publish message using mix as mix protocol is not mounted"
|
if not node.wakuMix.isNil():
|
||||||
|
lmixify = true
|
||||||
|
|
||||||
|
let
|
||||||
|
#[ error "failed to publish message using mix as mix protocol is not mounted"
|
||||||
return lighpushErrorResult(
|
return lighpushErrorResult(
|
||||||
LightPushErrorCode.SERVICE_NOT_AVAILABLE, "Waku lightpush with mix not available"
|
LightPushErrorCode.SERVICE_NOT_AVAILABLE, "Waku lightpush with mix not available"
|
||||||
)
|
) ]#
|
||||||
let toPeer: RemotePeerInfo = peerOpt.valueOr:
|
toPeer: RemotePeerInfo = peerOpt.valueOr:
|
||||||
if not node.wakuLightPush.isNil():
|
if not node.wakuLightPush.isNil():
|
||||||
RemotePeerInfo.init(node.peerId())
|
RemotePeerInfo.init(node.peerId())
|
||||||
elif not node.wakuLightpushClient.isNil():
|
elif not node.wakuLightpushClient.isNil():
|
||||||
@ -280,4 +284,4 @@ proc lightpushPublish*(
|
|||||||
error "lightpush publish error", error = msg
|
error "lightpush publish error", error = msg
|
||||||
return lighpushErrorResult(LightPushErrorCode.INTERNAL_SERVER_ERROR, msg)
|
return lighpushErrorResult(LightPushErrorCode.INTERNAL_SERVER_ERROR, msg)
|
||||||
|
|
||||||
return await lightpushPublishHandler(node, pubsubForPublish, message, toPeer, mixify)
|
return await lightpushPublishHandler(node, pubsubForPublish, message, toPeer, lmixify)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user