correct user access
This commit is contained in:
parent
54f223ac99
commit
b30971598e
2 changed files with 41 additions and 16 deletions
|
|
@ -12,8 +12,8 @@ const Utils = require('../utils')
|
|||
*/
|
||||
const getAnUser = async publicKey => {
|
||||
const oldProfile = await Utils.tryAndWait(
|
||||
g => {
|
||||
const user = g.get(`~${publicKey}`)
|
||||
(g, u) => {
|
||||
const user = u._.sea.pub === publicKey ? u : g.user(publicKey)
|
||||
|
||||
return new Promise(res => user.get(Key.PROFILE).load(res))
|
||||
},
|
||||
|
|
@ -21,25 +21,29 @@ const getAnUser = async publicKey => {
|
|||
)
|
||||
|
||||
const bio = await Utils.tryAndWait(
|
||||
g =>
|
||||
g
|
||||
.get(`~${publicKey}`)
|
||||
.get(Key.BIO)
|
||||
.then(),
|
||||
(g, u) => {
|
||||
const user = u._.sea.pub === publicKey ? u : g.user(publicKey)
|
||||
|
||||
return user.get(Key.BIO).then()
|
||||
},
|
||||
v => typeof v !== 'string'
|
||||
)
|
||||
|
||||
const lastSeenApp = await Utils.tryAndWait(
|
||||
g =>
|
||||
g
|
||||
.get(`~${publicKey}`)
|
||||
.get(Key.LAST_SEEN_APP)
|
||||
.then(),
|
||||
(g, u) => {
|
||||
const user = u._.sea.pub === publicKey ? u : g.user(publicKey)
|
||||
|
||||
return user.get(Key.LAST_SEEN_APP).then()
|
||||
},
|
||||
v => typeof v !== 'number'
|
||||
)
|
||||
|
||||
const lastSeenNode = await Utils.tryAndWait(
|
||||
(_, user) => user.get(Key.LAST_SEEN_NODE).then(),
|
||||
(g, u) => {
|
||||
const user = u._.sea.pub === publicKey ? u : g.user(publicKey)
|
||||
|
||||
return user.get(Key.LAST_SEEN_NODE).then()
|
||||
},
|
||||
v => typeof v !== 'number'
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,14 @@ const Wall = require('./user')
|
|||
const getWallTotalPages = async publicKey => {
|
||||
const totalPages = await Utils.tryAndWait(
|
||||
(gun, u) => {
|
||||
const user = publicKey ? gun.get(`~${publicKey}`) : u
|
||||
/**
|
||||
* @type {import('../SimpleGUN').GUNNode}
|
||||
*/
|
||||
let user = u
|
||||
|
||||
if (publicKey && u._.sea.pub !== publicKey) {
|
||||
user = gun.user(publicKey)
|
||||
}
|
||||
|
||||
return user
|
||||
.get(Key.WALL)
|
||||
|
|
@ -65,7 +72,14 @@ const getWallPage = async (page, publicKey) => {
|
|||
// @ts-ignore
|
||||
const count = await Utils.tryAndWait(
|
||||
(g, u) => {
|
||||
const user = publicKey ? g.get(`~${publicKey}`) : u
|
||||
/**
|
||||
* @type {import('../SimpleGUN').GUNNode}
|
||||
*/
|
||||
let user = u
|
||||
|
||||
if (publicKey && u._.sea.pub === publicKey) {
|
||||
user = g.user(publicKey)
|
||||
}
|
||||
|
||||
return user
|
||||
.get(Key.WALL)
|
||||
|
|
@ -86,7 +100,14 @@ const getWallPage = async (page, publicKey) => {
|
|||
*/
|
||||
const thePage = await Utils.tryAndWait(
|
||||
(g, u) => {
|
||||
const user = publicKey ? g.get(`~${publicKey}`) : u
|
||||
/**
|
||||
* @type {import('../SimpleGUN').GUNNode}
|
||||
*/
|
||||
let user = u
|
||||
|
||||
if (publicKey && u._.sea.pub) {
|
||||
user = g.user(publicKey)
|
||||
}
|
||||
|
||||
return new Promise(res => {
|
||||
user
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue