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 getAnUser = async publicKey => {
|
||||||
const oldProfile = await Utils.tryAndWait(
|
const oldProfile = await Utils.tryAndWait(
|
||||||
g => {
|
(g, u) => {
|
||||||
const user = g.get(`~${publicKey}`)
|
const user = u._.sea.pub === publicKey ? u : g.user(publicKey)
|
||||||
|
|
||||||
return new Promise(res => user.get(Key.PROFILE).load(res))
|
return new Promise(res => user.get(Key.PROFILE).load(res))
|
||||||
},
|
},
|
||||||
|
|
@ -21,25 +21,29 @@ const getAnUser = async publicKey => {
|
||||||
)
|
)
|
||||||
|
|
||||||
const bio = await Utils.tryAndWait(
|
const bio = await Utils.tryAndWait(
|
||||||
g =>
|
(g, u) => {
|
||||||
g
|
const user = u._.sea.pub === publicKey ? u : g.user(publicKey)
|
||||||
.get(`~${publicKey}`)
|
|
||||||
.get(Key.BIO)
|
return user.get(Key.BIO).then()
|
||||||
.then(),
|
},
|
||||||
v => typeof v !== 'string'
|
v => typeof v !== 'string'
|
||||||
)
|
)
|
||||||
|
|
||||||
const lastSeenApp = await Utils.tryAndWait(
|
const lastSeenApp = await Utils.tryAndWait(
|
||||||
g =>
|
(g, u) => {
|
||||||
g
|
const user = u._.sea.pub === publicKey ? u : g.user(publicKey)
|
||||||
.get(`~${publicKey}`)
|
|
||||||
.get(Key.LAST_SEEN_APP)
|
return user.get(Key.LAST_SEEN_APP).then()
|
||||||
.then(),
|
},
|
||||||
v => typeof v !== 'number'
|
v => typeof v !== 'number'
|
||||||
)
|
)
|
||||||
|
|
||||||
const lastSeenNode = await Utils.tryAndWait(
|
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'
|
v => typeof v !== 'number'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,14 @@ const Wall = require('./user')
|
||||||
const getWallTotalPages = async publicKey => {
|
const getWallTotalPages = async publicKey => {
|
||||||
const totalPages = await Utils.tryAndWait(
|
const totalPages = await Utils.tryAndWait(
|
||||||
(gun, u) => {
|
(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
|
return user
|
||||||
.get(Key.WALL)
|
.get(Key.WALL)
|
||||||
|
|
@ -65,7 +72,14 @@ const getWallPage = async (page, publicKey) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const count = await Utils.tryAndWait(
|
const count = await Utils.tryAndWait(
|
||||||
(g, u) => {
|
(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
|
return user
|
||||||
.get(Key.WALL)
|
.get(Key.WALL)
|
||||||
|
|
@ -86,7 +100,14 @@ const getWallPage = async (page, publicKey) => {
|
||||||
*/
|
*/
|
||||||
const thePage = await Utils.tryAndWait(
|
const thePage = await Utils.tryAndWait(
|
||||||
(g, u) => {
|
(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 => {
|
return new Promise(res => {
|
||||||
user
|
user
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue