Skip to content
Snippets Groups Projects
Select Git revision
  • 03fe45d2dfcd50a495039f4c66d4f49fbf723f89
  • release default
  • 11-22-implement-kv-interface-defined-in-collectiveversionedkvgo
  • master protected
  • XX-4688/DbEncoding
  • hotfix/update
  • @XX-4682/Files
  • hotfix/XX-4655
  • dev protected
  • project/HavenNotifications
  • XX-4602/SilentMessageType
  • jono/npmTest
  • wasmTest2
  • XX-4461/FileUpload
  • XX-4505/blockuser
  • XX-4441
  • Jakub/Emoji-CI-Test
  • testing/websockets
  • fastReg
  • fast-registration
  • NewHostPool
  • v0.3.22
  • v0.3.21
  • v0.3.20
  • v0.3.18
  • v0.3.17
  • v0.3.16
  • v0.3.15
  • v0.3.14
  • v0.3.13
  • v0.3.12
  • v0.3.11
  • v0.3.10
  • v0.3.9
  • v0.3.8
  • v0.3.7
  • v0.3.6
  • v0.3.5
  • v0.3.4
  • 812b395df518ce096d01d5292596ca26f8fe92d9c4487ddfa515e190a51aa1a1
  • 76ba08e2dfa1798412a265404fa271840b52c035869111fce8e8cdb23a036a5a
41 results

params.go

Blame
  • udb.go 1.89 KiB
    ///////////////////////////////////////////////////////////////////////////////
    // Copyright © 2020 xx network SEZC                                          //
    //                                                                           //
    // Use of this source code is governed by a license that can be found in the //
    // LICENSE file                                                              //
    ///////////////////////////////////////////////////////////////////////////////
    
    package cmd
    
    import (
    	jww "github.com/spf13/jwalterweatherman"
    	"gitlab.com/elixxir/client/api"
    	"gitlab.com/xx_network/primitives/id"
    	"strings"
    	//"time"
    )
    
    type callbackSearch struct{}
    
    func (cs callbackSearch) Callback(userID, pubKey []byte, err error) {
    	if err != nil {
    		jww.INFO.Printf("UDB search failed: %v\n", err.Error())
    	} else if len(pubKey) == 0 {
    		jww.INFO.Printf("Public Key returned is empty\n")
    	} else {
    		userID, err := id.Unmarshal(userID)
    		if err != nil {
    			jww.ERROR.Printf("Malformed user ID from successful UDB search: %v", err)
    		}
    		jww.INFO.Printf("UDB search successful. Returned user %v\n",
    			userID)
    	}
    }
    
    var searchCallback = callbackSearch{}
    
    // Determines what UDB send function to call based on the text in the message
    func parseUdbMessage(msg string, client *api.Client) {
    	// Split the message on spaces
    	args := strings.Fields(msg)
    	if len(args) < 3 {
    		jww.ERROR.Printf("UDB command must have at least three arguments!")
    	}
    	// The first arg is the command
    	// the second is the valueType
    	// the third is the value
    	keyword := args[0]
    	// Case-insensitive match the keyword to a command
    	if strings.EqualFold(keyword, "SEARCH") {
    		//client.SearchForUser(args[2], searchCallback, 2*time.Minute)
    	} else if strings.EqualFold(keyword, "REGISTER") {
    		jww.ERROR.Printf("UDB REGISTER not allowed, it is already done during user registration")
    	} else {
    		jww.ERROR.Printf("UDB command not recognized!")
    	}
    }