git ssb

16+

Dominic / patchbay



Tree: 1c2926f12ff8e365e1d469f23180b50d50b9c749

Files: 1c2926f12ff8e365e1d469f23180b50d50b9c749 / app / sync / locationId.js

586 bytesRaw
1const nest = require('depnest')
2const get = require('lodash/get')
3const { isMsg } = require('ssb-ref')
4
5exports.gives = nest({ 'app.sync.locationId': true })
6
7exports.create = function (api) {
8 return nest('app.sync.locationId', locationId)
9
10 function locationId (location) {
11 if (typeof location === 'string') return location
12
13 if (isMsg(location.key)) {
14 // for all messages make the thread root key the 'locationId'
15 const key = get(location, 'value.content.root', location.key)
16 return JSON.stringify({ key })
17 }
18
19 return JSON.stringify(location)
20 }
21}
22

Built with git-ssb-web