mirror of
https://github.com/PretendoNetwork/friends.git
synced 2024-06-01 11:37:53 -04:00
8d8a05a7e2
Now database getters do error handling aswell, and in case of any error, the NEX or GRPC method throws a proper error about it. There are still some doubts on how to handle errors when a list of data is processed, so for now skip that element on the list and continue. Also add some constant errors to do better error handling.
27 lines
693 B
Go
27 lines
693 B
Go
package database_wiiu
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/PretendoNetwork/friends/database"
|
|
"github.com/PretendoNetwork/nex-go"
|
|
)
|
|
|
|
// SetUserBlocked marks a blocked PID as blocked on a bloker PID block list
|
|
func SetUserBlocked(blockerPID uint32, blockedPID uint32, titleId uint64, titleVersion uint16) error {
|
|
date := nex.NewDateTime(0)
|
|
date.FromTimestamp(time.Now())
|
|
|
|
_, err := database.Postgres.Exec(`
|
|
INSERT INTO wiiu.blocks (blocker_pid, blocked_pid, title_id, title_version, date)
|
|
VALUES ($1, $2, $3, $4, $5)
|
|
ON CONFLICT (blocker_pid, blocked_pid)
|
|
DO UPDATE SET
|
|
date = $5`, blockerPID, blockedPID, titleId, titleVersion, date.Value())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|