Commit 4d2f823a8d3ddc38e69dddc7955b69fc2f5574cf
move message encryption into sbot-publish
Dominic Tarr committed on 7/15/2016, 1:12:07 AMParent: b584acdb7216737141340d6bd53a13659b7b88cc
Files changed
modules/compose.js | changed |
modules/crypto.js | changed |
modules/message-confirm.js | changed |
sbot-api.js | changed |
modules/compose.js | ||
---|---|---|
@@ -7,9 +7,9 @@ | ||
7 | 7 | |
8 | 8 | var plugs = require('../plugs') |
9 | 9 | |
10 | 10 | //var suggest = plugs.map(exports.suggest = []) |
11 | -var publish = plugs.first(exports.publish = []) | |
11 | +var publish = plugs.first(exports.sbot_publish = []) | |
12 | 12 | var message_content = plugs.first(exports.message_content = []) |
13 | 13 | var message_confirm = plugs.first(exports.message_confirm = []) |
14 | 14 | var file_input = plugs.first(exports.file_input = []) |
15 | 15 | |
@@ -108,8 +108,4 @@ | ||
108 | 108 | return composer |
109 | 109 | |
110 | 110 | } |
111 | 111 | |
112 | - | |
113 | - | |
114 | - | |
115 | - |
modules/message-confirm.js | ||
---|---|---|
@@ -4,9 +4,9 @@ | ||
4 | 4 | //publish or add |
5 | 5 | |
6 | 6 | var plugs = require('../plugs') |
7 | 7 | |
8 | -var publish = plugs.first(exports.publish = []) | |
8 | +var publish = plugs.first(exports.sbot_publish = []) | |
9 | 9 | var message_content = plugs.first(exports.message_content = []) |
10 | 10 | |
11 | 11 | exports.message_confirm = function (content, cb) { |
12 | 12 |
sbot-api.js | ||
---|---|---|
@@ -1,8 +1,10 @@ | ||
1 | 1 | var pull = require('pull-stream') |
2 | 2 | var crypto = require('crypto') |
3 | +var ref = require('ssb-ref') | |
3 | 4 | var Reconnect = require('pull-reconnect') |
4 | 5 | |
6 | + | |
5 | 7 | function Hash (onHash) { |
6 | 8 | var hash = crypto.createHash('sha256') |
7 | 9 | return pull.through(function (data) { |
8 | 10 | hash.update( |
@@ -23,10 +25,10 @@ | ||
23 | 25 | var createConfig = require('ssb-config/inject') |
24 | 26 | |
25 | 27 | var createFeed = require('ssb-feed') |
26 | 28 | var keys = require('./keys') |
29 | +var ssbKeys = require('ssb-keys') | |
27 | 30 | |
28 | - | |
29 | 31 | module.exports = function () { |
30 | 32 | var opts = createConfig() |
31 | 33 | var sbot = null |
32 | 34 | |
@@ -88,11 +90,18 @@ | ||
88 | 90 | }), |
89 | 91 | sbot_get: rec.async(function (key, cb) { |
90 | 92 | sbot.get(key, cb) |
91 | 93 | }), |
92 | - sbot_publish: rec.async(function (msg, cb) { | |
93 | - feed.add(msg, function (err, msg) { | |
94 | - cb(err, msg) | |
94 | + sbot_publish: rec.async(function (content, cb) { | |
95 | + if(content.recps) | |
96 | + content = ssbKeys.box(content, content.recps.map(function (e) { | |
97 | + return ref.isFeed(e) ? e : e.link | |
98 | + })) | |
99 | + | |
100 | + feed.add(content, function (err, msg) { | |
101 | + if(err) console.error(err) | |
102 | + else if(!cb) console.log(msg) | |
103 | + cb && cb(err, msg) | |
95 | 104 | }) |
96 | 105 | }), |
97 | 106 | sbot_whoami: rec.async(function (cb) { |
98 | 107 | sbot.whoami(cb) |
@@ -100,4 +109,6 @@ | ||
100 | 109 | } |
101 | 110 | } |
102 | 111 | |
103 | 112 | |
113 | + | |
114 | + |
Built with git-ssb-web