]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/transaction_handlers.go
Remove use of relative paths
[rbdr/mobius] / hotline / transaction_handlers.go
index b06297dc6926169d2dceebcb69e96ad699b1e746..5773d80375d5d871380f3501c355f28d1ab6e2ea 100644 (file)
@@ -300,7 +300,7 @@ func HandleChatSend(cc *ClientConn, t *Transaction) (res []Transaction, err erro
        // *** Halcyon does stuff
        // This is indicated by the presence of the optional field fieldChatOptions in the transaction payload
        if t.GetField(fieldChatOptions).Data != nil {
-               formattedMsg = fmt.Sprintf("*** %s %s\r", *cc.UserName, t.GetField(fieldData).Data)
+               formattedMsg = fmt.Sprintf("\r*** %s %s", *cc.UserName, t.GetField(fieldData).Data)
        }
 
        if bytes.Equal(t.GetField(fieldData).Data, []byte("/stats")) {
@@ -472,9 +472,9 @@ func HandleDeleteFile(cc *ClientConn, t *Transaction) (res []Transaction, err er
        fileName := string(t.GetField(fieldFileName).Data)
        filePath := cc.Server.Config.FileRoot + ReadFilePath(t.GetField(fieldFilePath).Data)
 
-       path := "./" + filePath + "/" + fileName
+       path := filePath + fileName
 
-       cc.Server.Logger.Debugw("Delete file", "src", filePath+"/"+fileName)
+       cc.Server.Logger.Debugw("Delete file", "src", path)
 
        fi, err := os.Stat(path)
        if err != nil {
@@ -505,8 +505,8 @@ func HandleDeleteFile(cc *ClientConn, t *Transaction) (res []Transaction, err er
 // HandleMoveFile moves files or folders. Note: seemingly not documented
 func HandleMoveFile(cc *ClientConn, t *Transaction) (res []Transaction, err error) {
        fileName := string(t.GetField(fieldFileName).Data)
-       filePath := "./" + cc.Server.Config.FileRoot + ReadFilePath(t.GetField(fieldFilePath).Data)
-       fileNewPath := "./" + cc.Server.Config.FileRoot + ReadFilePath(t.GetField(fieldFileNewPath).Data)
+       filePath :=  cc.Server.Config.FileRoot + ReadFilePath(t.GetField(fieldFilePath).Data)
+       fileNewPath :=  cc.Server.Config.FileRoot + ReadFilePath(t.GetField(fieldFileNewPath).Data)
 
        cc.Server.Logger.Debugw("Move file", "src", filePath+"/"+fileName, "dst", fileNewPath+"/"+fileName)
 
@@ -625,7 +625,6 @@ func HandleSetUser(cc *ClientConn, t *Transaction) (res []Transaction, err error
 
 func HandleGetUser(cc *ClientConn, t *Transaction) (res []Transaction, err error) {
        userLogin := string(t.GetField(fieldUserLogin).Data)
-       decodedUserLogin := NegatedUserString(t.GetField(fieldUserLogin).Data)
        account := cc.Server.Accounts[userLogin]
        if account == nil {
                errorT := cc.NewErrReply(t, "Account does not exist.")
@@ -635,7 +634,7 @@ func HandleGetUser(cc *ClientConn, t *Transaction) (res []Transaction, err error
 
        res = append(res, cc.NewReply(t,
                NewField(fieldUserName, []byte(account.Name)),
-               NewField(fieldUserLogin, []byte(decodedUserLogin)),
+               NewField(fieldUserLogin, negateString(t.GetField(fieldUserLogin).Data)),
                NewField(fieldUserPassword, []byte(account.Password)),
                NewField(fieldUserAccess, *account.Access),
        ))
@@ -1242,7 +1241,7 @@ func HandleDownloadFolder(cc *ClientConn, t *Transaction) (res []Transaction, er
 
        fp := NewFilePath(t.GetField(fieldFilePath).Data)
 
-       fullFilePath := fmt.Sprintf("./%v/%v", cc.Server.Config.FileRoot+fp.String(), string(fileTransfer.FileName))
+       fullFilePath := fmt.Sprintf("%v%v", cc.Server.Config.FileRoot+fp.String(), string(fileTransfer.FileName))
        transferSize, err := CalcTotalSize(fullFilePath)
        if err != nil {
                return res, err
@@ -1264,7 +1263,7 @@ func HandleDownloadFolder(cc *ClientConn, t *Transaction) (res []Transaction, er
 // Fields used in the request
 // 201 File name
 // 202 File path
-// 108 Transfer size   Total size of all items in the folder
+// 108 transfer size   Total size of all items in the folder
 // 220 Folder item count
 // 204 File transfer options   "Optional Currently set to 1" (TODO: ??)
 func HandleUploadFolder(cc *ClientConn, t *Transaction) (res []Transaction, err error) {