mirror of
https://github.com/notherealmarco/WASAPhoto.git
synced 2025-03-13 13:35:23 +01:00
Fix profile view follow & ban status, Add ban status in GET profile API call
This commit is contained in:
parent
00e6b3de7b
commit
4c4481393d
8 changed files with 39 additions and 16 deletions
8
.vscode/launch.json
vendored
8
.vscode/launch.json
vendored
|
@ -4,13 +4,17 @@
|
|||
// Per altre informazioni, visitare: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
|
||||
{
|
||||
"name": "Launch Package",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"buildFlags": "-tags webui",
|
||||
"program": "./cmd/webapi"
|
||||
"buildFlags": "",
|
||||
"program": "./cmd/webapi",
|
||||
"args": [
|
||||
"--db-filename", "/home/marco/wasa/wasadata/wasaphoto.db", "--data-path", "/home/marco/wasa/wasadata/data"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1005,6 +1005,8 @@ components:
|
|||
$ref: "#/components/schemas/photos_n"
|
||||
followed:
|
||||
$ref: "#/components/schemas/follow_status"
|
||||
banned:
|
||||
$ref: "#/components/schemas/ban_status"
|
||||
user_photo_stream:
|
||||
type: array
|
||||
minItems: 0
|
||||
|
|
|
@ -54,12 +54,21 @@ func (db *appdbimpl) GetUserProfile(uid string, requesting_uid string) (QueryRes
|
|||
return ERR_INTERNAL, nil, err
|
||||
}
|
||||
|
||||
// Get ban status
|
||||
var ban_status bool
|
||||
err = db.c.QueryRow(`SELECT EXISTS (SELECT * FROM "bans" WHERE "user" = ? AND "ban" = ?)`, requesting_uid, uid).Scan(&ban_status)
|
||||
|
||||
if err != nil {
|
||||
return ERR_INTERNAL, nil, err
|
||||
}
|
||||
|
||||
return SUCCESS, &structures.UserProfile{
|
||||
UID: uid,
|
||||
Name: name,
|
||||
Following: following,
|
||||
Followers: followers,
|
||||
Followed: follow_status,
|
||||
Banned: ban_status,
|
||||
Photos: photos,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -290,15 +290,15 @@ func (db *appdbimpl) SearchByName(name string, requesting_uid string, start_inde
|
|||
(
|
||||
SELECT EXISTS(
|
||||
SELECT * FROM "follows" AS "f"
|
||||
WHERE "f"."follower" = "users"."uid"
|
||||
AND "f"."followed" = ?
|
||||
WHERE "f"."follower" = ?
|
||||
AND "f"."followed" = "users"."uid"
|
||||
)
|
||||
),
|
||||
(
|
||||
SELECT EXISTS(
|
||||
SELECT * FROM "bans" AS "b"
|
||||
WHERE "b"."user" = "users"."uid"
|
||||
AND "b"."ban" = ?
|
||||
WHERE "b"."user" = ?
|
||||
AND "b"."ban" = "users"."uid"
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -10,10 +10,10 @@ type UIDName struct {
|
|||
}
|
||||
|
||||
type SearchResult struct {
|
||||
UID string `json:"user_id"`
|
||||
Name string `json:"name"`
|
||||
Followed bool `json:"followed"`
|
||||
Banned bool `json:"banned"`
|
||||
UID string `json:"user_id"`
|
||||
Name string `json:"name"`
|
||||
Followed bool `json:"followed"`
|
||||
Banned bool `json:"banned"`
|
||||
}
|
||||
|
||||
type GenericResponse struct {
|
||||
|
@ -52,5 +52,6 @@ type UserProfile struct {
|
|||
Following int64 `json:"following"`
|
||||
Followers int64 `json:"followers"`
|
||||
Followed bool `json:"followed"`
|
||||
Banned bool `json:"banned"`
|
||||
Photos int64 `json:"photos"`
|
||||
}
|
||||
|
|
BIN
wasaphoto.db
BIN
wasaphoto.db
Binary file not shown.
10
webui/node_modules/.vite/deps/_metadata.json
generated
vendored
10
webui/node_modules/.vite/deps/_metadata.json
generated
vendored
|
@ -1,23 +1,23 @@
|
|||
{
|
||||
"hash": "0c3e4771",
|
||||
"browserHash": "01248067",
|
||||
"hash": "80447977",
|
||||
"browserHash": "b98131b5",
|
||||
"optimized": {
|
||||
"axios": {
|
||||
"src": "../../axios/index.js",
|
||||
"file": "axios.js",
|
||||
"fileHash": "d8d02cf0",
|
||||
"fileHash": "6b5eae63",
|
||||
"needsInterop": true
|
||||
},
|
||||
"vue": {
|
||||
"src": "../../vue/dist/vue.runtime.esm-bundler.js",
|
||||
"file": "vue.js",
|
||||
"fileHash": "f8034b26",
|
||||
"fileHash": "de50261f",
|
||||
"needsInterop": false
|
||||
},
|
||||
"vue-router": {
|
||||
"src": "../../vue-router/dist/vue-router.mjs",
|
||||
"file": "vue-router.js",
|
||||
"fileHash": "b4ca170f",
|
||||
"fileHash": "4cad12d6",
|
||||
"needsInterop": false
|
||||
}
|
||||
},
|
||||
|
|
|
@ -2,6 +2,14 @@
|
|||
|
||||
export default {
|
||||
props: ["user_id", "name", "followed", "banned", "my_id", "show_new_post"],
|
||||
watch: {
|
||||
banned: function(new_val, old_val) {
|
||||
this.user_banned = new_val;
|
||||
},
|
||||
followed: function(new_val, old_val) {
|
||||
this.user_followed = new_val;
|
||||
},
|
||||
},
|
||||
data: function() {
|
||||
return {
|
||||
errorMsg: "aaa",
|
||||
|
@ -63,7 +71,6 @@ export default {
|
|||
},
|
||||
},
|
||||
created() {
|
||||
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue