[PD1] Logic all done?
This commit is contained in:
parent
cfe9f3c7b3
commit
4c141bbc6e
4 changed files with 31 additions and 34 deletions
|
@ -63,7 +63,6 @@ func (ds DataStore) GetMessage(toUID string, position int) protocol.Packet {
|
|||
SELECT fromUID, toUID, subject, body, timestamp
|
||||
FROM messages
|
||||
WHERE toUID = ?
|
||||
AND status = 0
|
||||
ORDER BY timestamp
|
||||
LIMIT 1 OFFSET ?
|
||||
`
|
||||
|
@ -81,10 +80,14 @@ func (ds DataStore) GetMessage(toUID string, position int) protocol.Packet {
|
|||
func (ds DataStore) MarkMessageInQueueAsRead(toUID string, position int) {
|
||||
query := `
|
||||
UPDATE messages
|
||||
SET status = 1
|
||||
WHERE toUID = ? AND status = 0
|
||||
ORDER BY timestamp
|
||||
LIMIT 1 OFFSET ?
|
||||
SET status = 1
|
||||
WHERE (fromUID,toUID,timestamp) = (
|
||||
SELECT fromUID,toUID,timestamp
|
||||
FROM messages
|
||||
WHERE toUID = ?
|
||||
ORDER BY timestamp
|
||||
LIMIT 1 OFFSET ?
|
||||
)
|
||||
`
|
||||
|
||||
// Execute the SQL statement
|
||||
|
|
|
@ -48,6 +48,7 @@ F:
|
|||
if active := connection.Send(message); !active {
|
||||
break F
|
||||
}
|
||||
dataStore.MarkMessageInQueueAsRead(UID, reqMsg.Num)
|
||||
case protocol.SubmitMsgPkt:
|
||||
submitMsg := protocol.UnmarshalSubmitMessagePacket(pac.Body)
|
||||
if submitMsg.ToUID != UID && dataStore.userExists(submitMsg.ToUID) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue