Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Shuffle/Shuffle-shared
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0elliot committed May 28, 2024
2 parents e3c2409 + a1fdca9 commit 7f8575e
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app_upload/stitcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,8 @@ func main() {
bucketName = os.Args[5]
}

appname := "shuffle-ai"
appversion := "1.0.0"
appname := "email"
appversion := "1.3.0"
err := deployConfigToBackend(appfolder, appname, appversion)
if err != nil {
log.Printf("[WARNING] Failed uploading config: %s", err)
Expand Down
29 changes: 28 additions & 1 deletion db-connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -7521,7 +7521,7 @@ func SetWorkflow(ctx context.Context, workflow Workflow, id string, optionalEdit
// New struct, to not add body, author etc
data, err := json.Marshal(workflow)
if err != nil {
log.Printf("[WARNING] Failed marshalling in getworkflow: %s", err)
log.Printf("[WARNING] Failed marshalling in set workflow: %s", err)
return nil
}

Expand Down Expand Up @@ -12803,3 +12803,30 @@ func DeleteDbIndex(ctx context.Context, index string) error {

return nil
}

func SetTraining(ctx context.Context, training Training) error {
if project.DbType == "opensearch" {
return errors.New("Not implemented")
}

if training.ID == "" {
training.ID = uuid.NewV4().String()
}

if training.SignupTime == 0 {
training.SignupTime = time.Now().Unix()
}

// Overwriting to be sure these are matching
// No real point in having id + workflow.ID anymore
nameKey := "training"

log.Printf("[INFO] Setting training with %d attendants", training.NumberOfAttendees)
key := datastore.NameKey(nameKey, training.ID, nil)
if _, err := project.Dbclient.Put(ctx, key, &training); err != nil {
log.Printf("[ERROR] Failed adding training with ID %s: %s", training.ID, err)
return err
}

return nil
}
21 changes: 17 additions & 4 deletions oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -4002,10 +4002,23 @@ func RunOauth2Request(ctx context.Context, user User, appAuth AppAuthenticationS
// FIXME: Does this work with string?
//https://stackoverflow.com/questions/43870554/microsoft-oauth2-authentication-not-returning-refresh-token
parsedTime := strconv.FormatInt(int64(time.Now().Unix())+int64(oauthResp.ExpiresIn), 10)
appAuth.Fields = append(appAuth.Fields, AuthenticationStore{
Key: "expiration",
Value: parsedTime,
})
if oauthResp.ExpiresIn > 0 {
newauth := []AuthenticationStore{}
for _, item := range appAuth.Fields {
if item.Key == "expiration" {
continue
}

newauth = append(newauth, item)
}

newauth = append(newauth, AuthenticationStore{
Key: "expiration",
Value: parsedTime,
})

appAuth.Fields = newauth
}

if len(refreshUrl) > 0 && !refresh {
log.Printf("[DEBUG] Appending Oauth2 Refresh URL %s", refreshUrl)
Expand Down
8 changes: 5 additions & 3 deletions shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -14565,7 +14565,8 @@ func handleKeyEncryption(data []byte, passphrase string) ([]byte, error) {
}

func HandleKeyDecryption(data []byte, passphrase string) ([]byte, error) {
log.Printf("[DEBUG] Passphrase: %s", passphrase)
//log.Printf("[DEBUG] Passphrase: %s", passphrase)
log.Printf("Decrypting key: %s", data)
key, err := create32Hash(passphrase)
if err != nil {
log.Printf("[ERROR] Failed hashing in decrypt: %s", err)
Expand Down Expand Up @@ -14600,7 +14601,8 @@ func HandleKeyDecryption(data []byte, passphrase string) ([]byte, error) {
nonce, ciphertext := parsedData[:nonceSize], parsedData[nonceSize:]
plaintext, err := gcm.Open(nil, nonce, ciphertext, nil)
if err != nil {
log.Printf("[ERROR] Error reading decryptionkey: %s - nonce: %s, ciphertext: %s", err, nonce, ciphertext)
//log.Printf("[ERROR] Error reading decryptionkey: %s - nonce: %s, ciphertext: %s", err, nonce, ciphertext)
log.Printf("[ERROR] Error reading decryptionkey: %s - nonce: %s", err, nonce)
return []byte{}, err
}

Expand Down Expand Up @@ -18830,7 +18832,7 @@ func PrepareWorkflowExecution(ctx context.Context, workflow Workflow, request *h
}

action.Parameters = append(action.Parameters, parameter)
log.Printf("[INFO] Adding parameter %s to subflow", parameter.Name)
//log.Printf("[INFO] Adding parameter %s to subflow", parameter.Name)
}

action.Parameters = append(action.Parameters, WorkflowAppActionParameter{
Expand Down
15 changes: 15 additions & 0 deletions structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3865,3 +3865,18 @@ type SSOResponse struct {
Reason string `json:"reason"`
URL string `json:"url"`
}

type Training struct {
Name string `json:"Name"`
Email string `json:"Email"`
NumberOfAttendees int `json:"numberOfAttendees"`
Message string `json:"Message"`
Time string `json:"Time"`
Country string `json:"Country"`

OrgId string `json:"org_id"`
UserId string `json:"user_id"`
Username string `json:"username"`
ID string `json:"id"`
SignupTime int64 `json:"signupTime"`
}

0 comments on commit 7f8575e

Please sign in to comment.