Browse Source

actual conn

feature/dockerfile-arm
Evan Feenstra 5 years ago
parent
commit
726c7aac24
  1. 2
      api/controllers/chats.ts
  2. 2
      api/network/receive.ts
  3. 9
      api/utils/tribes.ts
  4. 2
      config/app.json
  5. 2
      dist/api/network/receive.js
  6. 2
      dist/api/network/receive.js.map
  7. 9
      dist/api/utils/tribes.js
  8. 2
      dist/api/utils/tribes.js.map

2
api/controllers/chats.ts

@ -501,4 +501,4 @@ async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array);
}
}
}

2
api/network/receive.ts

@ -38,6 +38,8 @@ async function forwardMessageToTribe(payload){
const owner = await models.Contact.findOne({where:{isOwner:true}})
const type = payload.type
const message = payload.message
// HERE: NEED TO MAKE SURE ALIAS IS UNIQUE
// ASK xref TABLE and put alias there too?
sendMessage({
sender: {
...owner.dataValues, // ADD IN REAL ALIAS HERE??!

9
api/utils/tribes.ts

@ -17,8 +17,8 @@ export async function connect(onMessage) {
async function reconnect(){
client = null
const pwd = await genSignedTimestamp()
console.log('[tribes] try to connect:',`tcp://${config.tribes_host}`)
client = mqtt.connect(`tcp://${config.tribes_host}`,{
console.log('[tribes] try to connect:',`tls://${config.tribes_host}`)
client = mqtt.connect(`tls://${config.tribes_host}`,{
username:info.identity_pubkey,
password:pwd,
reconnectPeriod:0, // dont auto reconnect
@ -27,9 +27,12 @@ export async function connect(onMessage) {
console.log("[tribes] connected!")
client.subscribe(`${info.identity_pubkey}/#`)
})
client.on('close', function () {
client.on('close', function (e) {
setTimeout(()=> reconnect(), 2000)
})
client.on('error', function (e) {
console.log('[tribes] error: ',e)
})
client.on('message', function(topic, message) {
if(onMessage) onMessage(topic, message)
})

2
config/app.json

@ -12,7 +12,7 @@
"hub_invite_url": "http://lvh.me/invites",
"hub_check_invite_url": "http://lvh.me/check_invite",
"media_host": "localhost:5000",
"tribes_host": "127.0.0.1:1883"
"tribes_host": "tribes.sphinx.chat:8883"
},
"production": {
"senza_url": "https://staging.senza.us/api/v2/",

2
dist/api/network/receive.js

@ -50,6 +50,8 @@ function forwardMessageToTribe(payload) {
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
const type = payload.type;
const message = payload.message;
// HERE: NEED TO MAKE SURE ALIAS IS UNIQUE
// ASK xref TABLE and put alias there too?
send_1.sendMessage({
sender: Object.assign(Object.assign({}, owner.dataValues), payload.sender && payload.sender.alias && { alias: payload.sender.alias }),
chat, type, message,

2
dist/api/network/receive.js.map

File diff suppressed because one or more lines are too long

9
dist/api/utils/tribes.js

@ -25,8 +25,8 @@ function connect(onMessage) {
return __awaiter(this, void 0, void 0, function* () {
client = null;
const pwd = yield genSignedTimestamp();
console.log('[tribes] try to connect:', `tcp://${config.tribes_host}`);
client = mqtt.connect(`tcp://${config.tribes_host}`, {
console.log('[tribes] try to connect:', `tls://${config.tribes_host}`);
client = mqtt.connect(`tls://${config.tribes_host}`, {
username: info.identity_pubkey,
password: pwd,
reconnectPeriod: 0,
@ -35,9 +35,12 @@ function connect(onMessage) {
console.log("[tribes] connected!");
client.subscribe(`${info.identity_pubkey}/#`);
});
client.on('close', function () {
client.on('close', function (e) {
setTimeout(() => reconnect(), 2000);
});
client.on('error', function (e) {
console.log('[tribes] error: ', e);
});
client.on('message', function (topic, message) {
if (onMessage)
onMessage(topic, message);

2
dist/api/utils/tribes.js.map

@ -1 +1 @@
{"version":3,"file":"tribes.js","sourceRoot":"","sources":["../../../api/utils/tribes.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,iCAAgC;AAChC,qCAAoC;AACpC,mCAAkC;AAClC,6BAA4B;AAC5B,6BAA4B;AAE5B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa,CAAA;AACjD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAC,uBAAuB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAEzE,IAAI,MAAU,CAAA;AAEd,SAAsB,OAAO,CA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