Giter Site home page Giter Site logo

Comments (2)

soapdog avatar soapdog commented on May 24, 2024 1

@clehner I ended up pushing a removal of the code that relied on ssb-conn before seeing the PR you sent. The code below your changes was part of trying to implement Rooms 2.0 HTTP Auth but it didn't work, and it couldn't work because the flow needs to happen in the backend, not the front-end. In essence, that code was a leftover from an attempt to implement a feature.

This commit pushes both that removal, a version bump, and a prebuilt webextension in the dist/ folder. It should work for you and fix #113

Be aware that there is one last piece of code that relies in ssb-conn to work and that is joining rooms 2.0.

From src/core/platforms/ssb/rooms2.js:

  connectAndRemember: (address) => {
    return new Promise((resolve, reject) => { 
      ssb.sbot.conn.connect(address, (err, data) => {
        if (err) {
          reject(err)
        } else {
          ssb.sbot.conn.remember(address)
          resolve({address, data})
        }
      })
    })
  },

I will figure out a way to provide a version of that that doesn't rely on ssb-conn. Do you have any tips about how to do it?

Except for that feature, the rest of Patchfox should work for you now. Unless there are other plugins I'm relying on that you don't have, but that is good because I want to make this more agnostic and would gladly patch patchfox to solve these situations.

from patchfox.

clehner avatar clehner commented on May 24, 2024

@soapdog I would suggest to call sbot.gossip.connect if ssb-gossip is present and not ssb-conn.
I don't think a separate "remember" step is needed, since although ssb-gossip has gossip.add, the gossip.connect implementation calls it already internally.
I haven't tested this with actual rooms.

From 021296dd70aa9e1098663ac50d4d42320608b224 Mon Sep 17 00:00:00 2001
From: "Charles E. Lehner" <[email protected]>
Date: Mon, 14 Jun 2021 21:17:49 -0400
Subject: [PATCH] Support ssb-gossip in connectAndRemember

---
 src/core/platforms/ssb/rooms2.js | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/core/platforms/ssb/rooms2.js b/src/core/platforms/ssb/rooms2.js
index fdad5c9..41beb63 100644
--- a/src/core/platforms/ssb/rooms2.js
+++ b/src/core/platforms/ssb/rooms2.js
@@ -17,11 +17,19 @@ const rooms2 = {
   },
   connectAndRemember: (address) => {
     return new Promise((resolve, reject) => { 
-      ssb.sbot.conn.connect(address, (err, data) => {
+      let gossipOrConn = ssb.sbot.gossip || ssb.sbot.conn
+      if (!gossipOrConn) {
+        return reject(new Error('Missing ssb-gossip or ssb-conn'))
+      }
+      gossipOrConn.connect(address, (err, data) => {
         if (err) {
           reject(err)
         } else {
-          ssb.sbot.conn.remember(address)
+          if (ssb.sbot.conn) {
+            ssb.sbot.conn.remember(address)
+          } else {
+            // gossip.connect calls gossip.add internally
+          }
           resolve({address, data})
         }
       })
-- 
2.30.2

from patchfox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.