Don't be a Nyo

This commit is contained in:
Howl 2016-04-08 18:18:42 +02:00
parent 0d1a298065
commit 7b82c98352

View File

@ -132,10 +132,11 @@ func FriendsWithGET(md common.MethodData) (r common.Response) {
r.Data = d r.Data = d
return return
} }
md.DB.QueryRow("SELECT EXISTS(SELECT 1 FROM users_relationships WHERE user1 = ? AND user2 = ? LIMIT 1)", md.User.UserID, uid).Scan(&d.Friends) err = md.DB.QueryRow("SELECT EXISTS(SELECT 1 FROM users_relationships WHERE user1 = ? AND user2 = ? LIMIT 1), EXISTS(SELECT 1 FROM users_relationships WHERE user2 = ? AND user1 = ? LIMIT 1)", md.User.UserID, uid, md.User.UserID, uid).Scan(&d.Friends, &d.Mutual)
if d.Friends { if err != sql.ErrNoRows && err != nil {
// Nyo mode: activated md.C.Error(err)
md.DB.QueryRow("SELECT EXISTS(SELECT 1 FROM users_relationships WHERE user2 = ? AND user1 = ? LIMIT 1)", md.User.UserID, uid).Scan(&d.Mutual) r = Err500
return
} }
r.Data = d r.Data = d
return return