-
Notifications
You must be signed in to change notification settings - Fork 19
Messaging system #158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ChayanDass
wants to merge
1
commit into
fossology:main
Choose a base branch
from
ChayanDass:mail2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Messaging system #158
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| // SPDX-FileCopyrightText: 2023 Siemens AG | ||
| // SPDX-FileContributor: Gaurav Mishra <[email protected]> | ||
| // SPDX-FileContributor: Dearsh Oberoi <[email protected]> | ||
| // SPDX-FileContributor: 2025 Chayan Das <[email protected]> | ||
| // | ||
| // SPDX-License-Identifier: GPL-2.0-only | ||
|
|
||
|
|
@@ -12,16 +13,21 @@ import ( | |
| "flag" | ||
| "log" | ||
| "os" | ||
| "strconv" | ||
|
|
||
| "github.com/joho/godotenv" | ||
| "github.com/lestrrat-go/httprc/v3" | ||
| "github.com/lestrrat-go/jwx/v3/jwk" | ||
| "go.uber.org/zap" | ||
|
|
||
| _ "github.com/dave/jennifer/jen" | ||
| _ "github.com/fossology/LicenseDb/cmd/laas/docs" | ||
| "github.com/fossology/LicenseDb/pkg/api" | ||
| "github.com/fossology/LicenseDb/pkg/auth" | ||
| "github.com/fossology/LicenseDb/pkg/db" | ||
| "github.com/fossology/LicenseDb/pkg/email" | ||
| logger "github.com/fossology/LicenseDb/pkg/log" | ||
|
|
||
| "github.com/fossology/LicenseDb/pkg/utils" | ||
| "github.com/fossology/LicenseDb/pkg/validations" | ||
| ) | ||
|
|
@@ -39,21 +45,28 @@ func main() { | |
| if err != nil { | ||
| log.Fatalf("Error loading .env file") | ||
| } | ||
|
|
||
| flag.Parse() | ||
|
|
||
| // Start the email service | ||
| EnableSMTP, _ := strconv.ParseBool(os.Getenv("ENABLE_SMTP")) | ||
| if EnableSMTP { | ||
| if err := email.Init(); err != nil { | ||
| logger.LogFatal("Failed to initialize email service", zap.Error(err)) | ||
| } | ||
| } | ||
|
|
||
| if os.Getenv("TOKEN_HOUR_LIFESPAN") == "" || os.Getenv("API_SECRET") == "" || os.Getenv("DEFAULT_ISSUER") == "" { | ||
| log.Fatal("Mandatory environment variables not configured") | ||
| logger.LogFatal("Mandatory environment variables not configured") | ||
| } | ||
|
|
||
| if os.Getenv("JWKS_URI") != "" { | ||
| cache, err := jwk.NewCache(context.Background(), httprc.NewClient()) | ||
| if err != nil { | ||
| log.Fatalf("Failed to create a jwk.Cache from the oidc provider's URL: %s", err) | ||
| logger.LogFatal("Failed to create a jwk.Cache from the oidc provider's URL:", zap.Error(err)) | ||
| } | ||
|
|
||
| if err := cache.Register(context.Background(), os.Getenv("JWKS_URI")); err != nil { | ||
| log.Fatalf("Failed to create a jwk.Cache from the oidc provider's URL: %s", err) | ||
| logger.LogFatal("Failed to create a jwk.Cache from the oidc provider's URL:", zap.Error(err)) | ||
| } | ||
|
|
||
| auth.Jwks = cache | ||
|
|
@@ -76,8 +89,7 @@ func main() { | |
| } | ||
|
|
||
| r := api.Router() | ||
|
|
||
| if err := r.Run(); err != nil { | ||
| log.Fatalf("Error while running the server: %v", err) | ||
| logger.LogFatal("Error while running the server:", zap.Error(err)) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| # SPDX-License-Identifier: GPL-2.0-only | ||
| # SPDX-FileCopyrightText: FOSSology contributors | ||
| #SPDX-FileContributor: 2025 Chayan Das <[email protected]> | ||
|
|
||
| # How long the token can be valid | ||
| TOKEN_HOUR_LIFESPAN=24 | ||
|
|
@@ -49,4 +50,15 @@ DB_HOST=localhost | |
| # This value can be adjusted based on the requirements of the similarity search | ||
| # A lower value will result in more matches, while a higher value will be more strict | ||
| # Default is set to 0.7, but can be changed to a higher value like 0.8 or 0.9 for stricter matching | ||
| SIMILARITY_THRESHOLD = 0.8 | ||
| SIMILARITY_THRESHOLD = 0.8 | ||
|
|
||
|
|
||
| # SMTP Configuration | ||
| ENABLE_SMTP=false | ||
| SMTP_HOST=smtp.gmail.com | ||
| SMTP_PORT=587 | ||
| [email protected] | ||
| SMTP_PASSWORD=your_password | ||
| [email protected] | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,4 +45,17 @@ DB_HOST=localhost | |
| # This value can be adjusted based on the requirements of the similarity search | ||
| # A lower value will result in more matches, while a higher value will be more strict | ||
| # Default is set to 0.7, but can be changed to a higher value like 0.8 or 0.9 for stricter matching | ||
| SIMILARITY_THRESHOLD = 0.8 | ||
| SIMILARITY_THRESHOLD = 0.8 | ||
|
|
||
|
|
||
|
|
||
|
|
||
| # SMTP Configuration | ||
| ENABLE_SMTP=false | ||
| SMTP_HOST=smtp.gmail.com | ||
| SMTP_PORT=587 | ||
| [email protected] | ||
| SMTP_PASSWORD=your_password | ||
| [email protected] | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // SPDX-FileCopyrightText: 2025 Chayan Das <[email protected]> | ||
| // SPDX-License-Identifier: GPL-2.0-only | ||
|
|
||
| package email | ||
|
|
||
| import ( | ||
| "github.com/fossology/LicenseDb/pkg/db" | ||
| "github.com/fossology/LicenseDb/pkg/models" | ||
| ) | ||
|
|
||
| func FetchAdminEmails() ([]string, error) { | ||
| var emails []string | ||
| admin := "ADMIN" | ||
| err := db.DB. | ||
| Model(&models.User{}). | ||
| Where(&models.User{UserLevel: &admin}). // can add super_admin too | ||
| Pluck("user_email", &emails).Error | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return emails, nil | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename variable to enableSMTP