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

The read mail function uses absolute array index for mails #44

Open
BadDevilGrind opened this issue Jun 4, 2024 · 2 comments
Open

The read mail function uses absolute array index for mails #44

BadDevilGrind opened this issue Jun 4, 2024 · 2 comments
Assignees

Comments

@BadDevilGrind
Copy link

As the title describes, the read program utilizes the absolute array index for reading emails, instead of utilized the localised array created by the "mail" program.

This means that if I have set up mails for several users on the same server, they will get the following output from mail.

User 1:
[0]: "wtf"
[1]: "Please call me"

User 2:
[0]: "What are you doing saturday night?"

Assuming those are the only emails in the mailserver.json file, and in the order specified, it will work for User 1 to type either read 0 or read 1 and get the corresponding message, but whenever User 2 tries to write read 0, it gets an error message, and only by typing read 2 (as it is the third mail in the json) the user gets the mail.

@BadDevilGrind
Copy link
Author

BadDevilGrind commented Jun 5, 2024

Actually managed to fix it myself. I created a filter array in the read function.
I added const messageList = mailList.filter( (mail) => mail.to.includes( userDatabase.userId ) ); to the read function in kernel.js, and changed mailAtIndex to reference the messageList instead of mailList

@Lucas-C
Copy link
Collaborator

Lucas-C commented Jul 1, 2024

Hi @BadDevilGrind

Thank you for the bug report!
I missed it when you created this issue last month, maybe because you closed it quickly after.

I'm reopining it until it is properly fixed on our side, give that it also caused trouble to @Chamo1 in issue #45

Would you like to submit a Pull Request o integrate this fixup into https://github.com/jacksonbenete/email_terminal master branch?
Else I can handle it 🙂

@Lucas-C Lucas-C reopened this Jul 1, 2024
@Lucas-C Lucas-C self-assigned this Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants