jacksonbenete / email_terminal

For use in tabletop rpgs. Login: 8A73B5@trustno1 or admin@admin
https://jacksonbenete.github.io/email_terminal/
GNU General Public License v3.0
45 stars 142 forks source link

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

Open BadDevilGrind opened 4 months ago

BadDevilGrind commented 4 months ago

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:

[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 commented 3 months ago

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 commented 3 months ago

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 https://github.com/jacksonbenete/email_terminal/issues/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 🙂