mirror of
https://github.com/notherealmarco/WASAPhoto.git
synced 2025-05-06 04:42:36 +02:00
Fix query errors
This commit is contained in:
parent
09adc06e18
commit
ebb5c4e6f7
10 changed files with 73 additions and 32 deletions
|
@ -52,3 +52,20 @@ func (db *appdbimpl) photoExists(uid string, photo int64) (bool, error) {
|
|||
}
|
||||
return cnt > 0, nil
|
||||
}
|
||||
|
||||
func (db *appdbimpl) PhotoExists(uid string, photo int64, requesting_uid string) (bool, error) {
|
||||
|
||||
var cnt int64
|
||||
err := db.c.QueryRow(`SELECT COUNT(*) FROM "photos"
|
||||
WHERE "id" = ?
|
||||
AND "user" = ?
|
||||
AND "user" NOT IN (
|
||||
SELECT "bans"."user" FROM "bans"
|
||||
WHERE "bans"."user" = "photos"."user"
|
||||
AND "bans"."ban" = ?
|
||||
)`, photo, uid, requesting_uid).Scan(&cnt)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return cnt > 0, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue