mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
improve data getters methods
This commit is contained in:
parent
b78104d47c
commit
96af4b8b89
@ -5,20 +5,32 @@ export default class User {
|
||||
return window.app?.api.withEndpoints("main")
|
||||
}
|
||||
|
||||
static async data(username) {
|
||||
static async data(payload) {
|
||||
const token = await Session.decodedToken()
|
||||
|
||||
if (!token || !User.bridge) {
|
||||
return false
|
||||
}
|
||||
|
||||
return User.bridge.get.user(undefined, payload ?? { username: token.username })
|
||||
}
|
||||
|
||||
static async dataByUsername(username) {
|
||||
if (!username) {
|
||||
const token = await Session.decodedToken()
|
||||
|
||||
if (!token || !User.bridge) {
|
||||
return false
|
||||
}
|
||||
|
||||
username = token.username
|
||||
throw new Error("username is required")
|
||||
}
|
||||
|
||||
return User.bridge.get.user(undefined, { username })
|
||||
}
|
||||
|
||||
static async dataById(user_id) {
|
||||
if (!user_id) {
|
||||
throw new Error("user_id is required")
|
||||
}
|
||||
|
||||
return User.bridge.get.user(undefined, { _id: user_id })
|
||||
}
|
||||
|
||||
static async publicData() {
|
||||
const token = await Session.decodedToken()
|
||||
|
||||
@ -106,6 +118,19 @@ export default class User {
|
||||
return data
|
||||
}
|
||||
|
||||
static async getConnectedUsersFollowing() {
|
||||
if (!User.bridge) {
|
||||
return false
|
||||
}
|
||||
|
||||
const { data } = await app.api.customRequest("main", {
|
||||
method: "GET",
|
||||
url: "/connected_users_following",
|
||||
})
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
getData = async (payload, callback) => {
|
||||
const request = await User.bridge.get.user(undefined, { username: payload.username, _id: payload.user_id }, {
|
||||
parseData: false
|
||||
|
Loading…
x
Reference in New Issue
Block a user