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

Adding support to keep original Filename of Attachment and open more flexibility #645

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

fglueck
Copy link

@fglueck fglueck commented Dec 13, 2021

can be extend with settings like "OVERWRITE_EXISTING _FILES" or like "GENERATE_FILENAME_IF_FILE_EXISTS"...

Adding support for "original" Filename.
$mailbox->setAttachmentsFilenameMode(Mailbox::ATTACH_FILE_NAMERANDOM); # filename by random (old way)
$mailbox->setAttachmentsFilenameMode(Mailbox::ATTACH_FILE_NAMEORIGINAL); # filename by email
@Sebbo94BY Sebbo94BY changed the base branch from master to develop December 13, 2021 22:21
@Sebbo94BY
Copy link
Collaborator

@fglueck can you please resolve the conflicts?

@Sebbo94BY
Copy link
Collaborator

@fglueck friendly reminder :)

@Sebbo94BY Sebbo94BY changed the base branch from develop to master December 28, 2021 00:33
@Sebbo94BY
Copy link
Collaborator

Can you please also squash your commits at the end, so that it's only one?

It would be also cool, when the commit message would be Adding support for "original" Filename instead of Update Mailbox.php.

Thank you! :)

@fglueck
Copy link
Author

fglueck commented Jan 10, 2022

sorry I miss the button "Squash and merge".

Is it possible that you must first "allow" this?
https://github.blog/2016-04-01-squash-your-commits/

@Sebbo94BY
Copy link
Collaborator

I have unfortunately no permissions to change any settings of this project.

But you can usually rebase and squash locally and force push the changes, don't you?

Ok, if it's not possible, I also can squash and merge it through the buttons here. :)

@Sebbo94BY
Copy link
Collaborator

Wouldn't it be a bit more beautiful and more human readable, when there would be some more underscores in the constant names? Like this?

    public const ATTACH_FILE_NAME_RANDOM = 1; // Filename is unique (random)
    public const ATTACH_FILE_NAME_ORIGINAL = 2; // Filename is Attachment-Filename
    public const ATTACH_FILE_NAME_ITTERATED = 3; // Filename is Attachment-Filename but if allready exists it will be extend by Number (#nr)

@fglueck
Copy link
Author

fglueck commented Jan 14, 2022

Your right, I change the names and add itterated filename.

@Sebbo94BY
Copy link
Collaborator

Perfect, I've already seen it.

There are some more reviews (see above). :)

@fglueck
Copy link
Author

fglueck commented Jan 17, 2022

You meen the "squash" ? I never do this before... so I can try to do this...

@Sebbo94BY
Copy link
Collaborator

No, I mean these pending reviews in the code.

Adding support for "original" Filename.
$mailbox->setAttachmentsFilenameMode(Mailbox::ATTACH_FILE_NAME_RANDOM); # filename by random (old way)
$mailbox->setAttachmentsFilenameMode(Mailbox::ATTACH_FILE_NAME_ORIGINAL); # filename by email
Copy link
Collaborator

@Sebbo94BY Sebbo94BY left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, forgot to publish my review. 😞

public const ATTACH_FILE_NAMERANDOM = 1; // Filename is unique (random)
public const ATTACH_FILE_NAMEORIGINAL = 2; // Filename is Attachment-Filename
/** @var int */
protected $attachmentsFilenameMode = self::ATTACH_FILE_NAMERANDOM;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
protected $attachmentsFilenameMode = self::ATTACH_FILE_NAMERANDOM;
protected $attachmentsFilenameMode = self::ATTACH_FILE_NAMERANDOM;


public const ATTACH_FILE_NAMERANDOM = 1; // Filename is unique (random)
public const ATTACH_FILE_NAMEORIGINAL = 2; // Filename is Attachment-Filename
/** @var int */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** @var int */
/** @var int */

/**
* Set $this->setAttachmentsRandomFilename param.
*
* @param int $random ATTACH_FILE_NAMERANDOM, ATTACH_FILE_NAMEORIGINAL
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable in the comment should match the actual parameter variable.

Suggested change
* @param int $random ATTACH_FILE_NAMERANDOM, ATTACH_FILE_NAMEORIGINAL
* @param int $mode ATTACH_FILE_NAMERANDOM, ATTACH_FILE_NAMEORIGINAL

public function setAttachmentsFilenameMode(int $mode) : Mailbox
{
$this->attachmentsFilenameMode = $mode;
return $this;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this return here? Wouldn't be a void function enough?

*/
public function setAttachmentsFilenameMode(int $mode) : Mailbox
{
$this->attachmentsFilenameMode = $mode;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I miss a check here, which ensures, that only supported modes can be set. Something like this:

Suggested change
$this->attachmentsFilenameMode = $mode;
if (!defined($mode))
{
throw new UnexpectedValueException("The defined mode '$mode' is not supported. Supported modes: ATTACH_FILE_NAMERANDOM, ATTACH_FILE_NAMEORIGINAL");
}
$this->attachmentsFilenameMode = $mode;

Note: I haven't tested this code.

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

Successfully merging this pull request may close these issues.

2 participants