Skip to content

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

@dipakparmar

Description

@dipakparmar

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions