Skip to content
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

[FEAT]: Implement isSpam Function for rspamd-node-client #20

Open
dipakparmar opened this issue Sep 19, 2024 · 0 comments
Open

[FEAT]: Implement isSpam Function for rspamd-node-client #20

dipakparmar opened this issue Sep 19, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@dipakparmar
Copy link
Owner

dipakparmar commented Sep 19, 2024

We need to implement a new function called isSpam in the rspamd-node-client package. This function will take two parameters:

  1. The response from an rspamd check
  2. A user-provided configuration object

The isSpam function will determine whether an email scanned by rspamd should be classified as spam or not, based on the rspamd check results and user-defined criteria.

Implementation Details

  1. Create a new function isSpam(rspamdResponse, userConfig) in the package.

  2. The rspamdResponse parameter will be the object returned by rspamd after checking an email.

  3. The userConfig parameter will be an object containing user-defined settings for spam classification. This may include:

    • Spam score threshold
    • Action-based classification (e.g., classify as spam if rspamd action is "reject" or "add header")
    • Specific symbol-based rules
  4. Implement logic to analyze the rspamdResponse based on the userConfig settings.

  5. Return a boolean value: true if the email is classified as spam, false otherwise.

Example Usage

const rspamdClient = require('rspamd-node-client');

const rspamdResponse = await rspamdClient.checkEmail(emailContent);

const userConfig = {
  spamScoreThreshold: 5,
  spamActions: ['reject', 'add header'],
  spamSymbols: ['BAYES_SPAM']
};

const isSpam = rspamdClient.isSpam(rspamdResponse, userConfig);

if (isSpam) {
  console.log('Email classified as spam');
} else {
  console.log('Email is not spam');
}

Testing

  • Write unit tests to cover various scenarios, including different rspamd responses and user configurations.
  • Test edge cases, such as missing or invalid user configurations.

Documentation

  • Update the package README.md to include information about the new isSpam function.
  • Provide clear examples of how to use the function with different configuration options.

Acceptance Criteria

  1. The isSpam function is implemented and works correctly with rspamd responses.
  2. The function accepts and correctly interprets user-provided configuration options.
  3. Unit tests are written and passing.
  4. Documentation is updated to reflect the new functionality.
  5. The function is exported and accessible to users of the package.

By implementing this feature, we'll provide users of rspamd-node-client with a flexible way to determine if an email is spam based on rspamd results and their own criteria.

@dipakparmar dipakparmar added the enhancement New feature or request label Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant