From 57a54367a5f19df0888c3dffd225fa4f2e1d8bb2 Mon Sep 17 00:00:00 2001 From: Jonathan Barrow Date: Sat, 30 Oct 2021 02:24:33 -0400 Subject: [PATCH] Store friend requests --- add_friend_request.go | 2 ++ database.go | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/add_friend_request.go b/add_friend_request.go index 5325420..6459707 100644 --- a/add_friend_request.go +++ b/add_friend_request.go @@ -103,6 +103,8 @@ func addFriendRequest(err error, client *nex.Client, callID uint32, pid uint32, friendInfo.LastOnline = nex.NewDateTime(0) friendInfo.Unknown = 0 + saveFriendRequest(friendRequestID, senderPID, recipientPID, sentTime.Value(), expireTime.Value(), message) + recipientClient := client.Server().FindClientFromPID(recipientPID) if recipientClient != nil { diff --git a/database.go b/database.go index 372bfcf..5b8f6f9 100644 --- a/database.go +++ b/database.go @@ -269,6 +269,12 @@ func isFriendRequestBlocked(requesterPID uint32, requestedPID uint32) bool { return true } +func saveFriendRequest(friendRequestID uint64, senderPID uint32, recipientPID uint32, sentTime uint64, expireTime uint64, message string) { + if err := cassandraClusterSession.Query(`INSERT INTO pretendo_friends.friend_requests (id, sender_pid, recipient_pid, sent_on, expires_on, message) VALUES (?, ?, ?, ?, ?, ?) IF NOT EXISTS`, friendRequestID, senderPID, recipientPID, sentTime, expireTime, message).Exec(); err != nil { + log.Fatal(err) + } +} + ////////////////////////////// // // // MongoDB database methods //