Commit ba6ff211efff89c71d83c323c851ba1732b15a1f
reverse order of state argument in appendNew and throw errors where appropiate
Dominic Tarr committed on 9/22/2017, 9:04:16 PMParent: a7051e65b56caff3ad3d3a29c4bf59526525e225
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -99,10 +99,12 @@ | ||
99 | 99 … | return fstate |
100 | 100 … | } |
101 | 101 … | |
102 | 102 … | exports.append = function (state, msg) { |
103 | - if(state.error = exports.checkInvalid(flatState(state.feeds[msg.author]), msg)) | |
104 | - return state | |
103 … | + var err | |
104 … | + var _state = flatState(state.feeds[msg.author]) | |
105 … | + if(err = exports.checkInvalid(_state, msg)) | |
106 … | + throw err | |
105 | 107 … | |
106 | 108 … | else if(state.feeds[msg.author]) { |
107 | 109 … | var a = state.feeds[msg.author] |
108 | 110 … | a.id = exports.id(msg) |
@@ -152,9 +154,9 @@ | ||
152 | 154 … | return '%'+ssbKeys.hash(JSON.stringify(msg, null, 2)) |
153 | 155 … | } |
154 | 156 … | |
155 | 157 … | exports.appendNew = function (state, hmac_key, keys, content, timestamp) { |
156 | - var msg = exports.create(keys, hmac_key, state.feeds[keys.id], content, timestamp) | |
158 … | + var msg = exports.create(state.feeds[keys.id], keys, hmac_key, content, timestamp) | |
157 | 159 … | state = exports.append(state, msg) |
158 | 160 … | return state |
159 | 161 … | } |
160 | 162 … | |
@@ -176,4 +178,7 @@ | ||
176 | 178 … | */ |
177 | 179 … | |
178 | 180 … | |
179 | 181 … | |
182 … | + | |
183 … | + | |
184 … | + |
Built with git-ssb-web