]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/transaction_handlers.go
Simplify user idle check
[rbdr/mobius] / hotline / transaction_handlers.go
index ea6d087540ec9a03e9fc3071810772f6888dfcf8..5aa6984a727c8be82df7193c876adf6c83e2881c 100644 (file)
@@ -273,7 +273,7 @@ var TransactionHandlers = map[uint16]TransactionType{
                Handler: HandleSetUser,
        },
        tranUploadFile: {
-               Access:  accessUploadFile,
+               Access:  accessAlwaysAllow,
                DenyMsg: "You are not allowed to upload files.",
                Name:    "tranUploadFile",
                Handler: HandleUploadFile,
@@ -821,11 +821,8 @@ func (cc *ClientConn) notifyNewUserHasJoined() (res []Transaction, err error) {
 }
 
 func HandleTranAgreed(cc *ClientConn, t *Transaction) (res []Transaction, err error) {
-       bs := make([]byte, 2)
-       binary.BigEndian.PutUint16(bs, *cc.Server.NextGuestID)
-
+       cc.Agreed = true
        cc.UserName = t.GetField(fieldUserName).Data
-       *cc.ID = bs
        *cc.Icon = t.GetField(fieldUserIconID).Data
 
        options := t.GetField(fieldOptions).Data
@@ -1323,21 +1320,25 @@ func HandleUploadFolder(cc *ClientConn, t *Transaction) (res []Transaction, err
 }
 
 func HandleUploadFile(cc *ClientConn, t *Transaction) (res []Transaction, err error) {
+       // TODO: add permission handing for upload folders and drop boxes
+       if !authorize(cc.Account.Access, accessUploadFile) {
+               res = append(res, cc.NewErrReply(t, "You are not allowed to upload files."))
+               return res, err
+       }
+
        fileName := t.GetField(fieldFileName).Data
        filePath := t.GetField(fieldFilePath).Data
 
        transactionRef := cc.Server.NewTransactionRef()
        data := binary.BigEndian.Uint32(transactionRef)
 
-       fileTransfer := &FileTransfer{
+       cc.Server.FileTransfers[data] = &FileTransfer{
                FileName:        fileName,
                FilePath:        filePath,
                ReferenceNumber: transactionRef,
                Type:            FileUpload,
        }
 
-       cc.Server.FileTransfers[data] = fileTransfer
-
        res = append(res, cc.NewReply(t, NewField(fieldRefNum, transactionRef)))
        return res, err
 }
@@ -1398,9 +1399,9 @@ func HandleSetClientUserInfo(cc *ClientConn, t *Transaction) (res []Transaction,
        return res, err
 }
 
-// HandleKeepAlive response to keepalive transactions with an empty reply
-// HL 1.9.2 Client sends keepalive msg every 3 minutes
-// HL 1.2.3 Client doesn't send keepalives
+// HandleKeepAlive responds to keepalive transactions with an empty reply
+// HL 1.9.2 Client sends keepalive msg every 3 minutes
+// HL 1.2.3 Client doesn't send keepalives
 func HandleKeepAlive(cc *ClientConn, t *Transaction) (res []Transaction, err error) {
        res = append(res, cc.NewReply(t))