MCPcopy Index your code
hub / github.com/cryptpad/cryptpad / getSession

Function getSession

www/cryptpad-api.js:175–211  ·  view source on GitHub ↗
(cb)

Source from the content-addressed store, hash-verified

173 };
174
175 var getSession = function (cb) {
176 chan.send('GET_SESSION', {
177 key: key,
178 view: isView,
179 keepOld: !config.events.onNewKey
180 }, function (obj) {
181 if (isView && obj.error === 'ENOENT') {
182 key = obj.key;
183 return void cb();
184 }
185
186 if (obj && obj.error) { reject(obj.error); return console.error(obj.error); }
187
188 // OnlyOffice
189 if (!config.events.onNewKey) {
190 key = obj.key;
191 return void cb();
192 }
193
194 if (obj.key !== key) {
195 // The outside app may reject our new key if the "old" one is deprecated.
196 // This will happen if multiple users try to update the key at the same
197 // time and in this case, only the first user will be able to generate a key.
198 return config.events.onNewKey({
199 old: key,
200 new: obj.key,
201 view: obj.viewKey,
202 }, function (_key) {
203 // Delay reloading tabs with deprecated key
204 var to = _key !== obj.key ? 1000 : 0;
205 key = _key || obj.key;
206 setTimeout(cb, to);
207 });
208 }
209 cb();
210 });
211 };
212 getSession(onKeyValidated);
213
214 chan.on('DOCUMENT_READY', function () {

Callers 1

startFunction · 0.70

Calls 2

rejectFunction · 0.85
cbFunction · 0.50

Tested by

no test coverage detected