Commit d5541b9e authored by Mo Firouz's avatar Mo Firouz
Browse files

Add further hinting for friend state SQL query.

parent e0fd2593
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -149,7 +149,7 @@ func UserExistsAndDoesNotBlock(db *sql.DB, checkUserID, blocksUserID uuid.UUID)
	var count int
	err := db.QueryRow(`
SELECT COUNT(id) FROM users
WHERE id = $1 AND NOT EXISTS (
WHERE id = $1::UUID AND NOT EXISTS (
	SELECT state FROM user_edge
	WHERE source_id = $1::UUID AND destination_id = $2::UUID AND state = 3
)
+2 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import (
	"unicode/utf8"

	"database/sql"

	"github.com/golang/protobuf/ptypes/timestamp"
	"github.com/golang/protobuf/ptypes/wrappers"
	"github.com/heroiclabs/nakama/api"
@@ -119,6 +120,7 @@ func (p *Pipeline) channelJoin(logger *zap.Logger, session Session, envelope *rt
		// Check if the other user exists and has not blocked this user.
		allowed, err := UserExistsAndDoesNotBlock(p.db, uid, userID)
		if err != nil {
			logger.Warn("Failed to execute query to check user and friend block state", zap.Error(err), zap.String("uid", userID.String()), zap.String("friend", uid.String()))
			session.Send(false, 0, &rtapi.Envelope{Cid: envelope.Cid, Message: &rtapi.Envelope_Error{Error: &rtapi.Error{
				Code:    int32(rtapi.Error_RUNTIME_EXCEPTION),
				Message: "Failed to look up user ID",