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

owner-email is functional only with public projects #75

Closed
iprok opened this issue Apr 27, 2015 · 12 comments
Closed

owner-email is functional only with public projects #75

iprok opened this issue Apr 27, 2015 · 12 comments

Comments

@iprok
Copy link

iprok commented Apr 27, 2015

We use current git version of the plugin and redmine 2.6.4. The issue is that owner-email is filled and helpdesk-first-reply is sent only when project has "public" status. It will be quite nice to use the functionality with private projects too.

@iprok
Copy link
Author

iprok commented Apr 27, 2015

I mean that will be nice that unregistered anonymous users would be able to write to private projects.

@vilppuvuorinen
Copy link
Contributor

I think this can be done by adding Anonymous Users group as a member to the private project. However, you'll end up breaking the intended functionality of the non-public setting. If disabling permission check in the rake task fetching the emails does not help, it will take some fiddling around to break the ACLs just a little.

@jfqd
Copy link
Owner

jfqd commented Apr 28, 2015

I don´t see a need for this with a proper user and role management of projects.

@jfqd jfqd closed this as completed Apr 28, 2015
@BRUTEF0RCE
Copy link

Has anyone succeeded at receiving anonymous email information in the issue custom field owner-email in a private project and with Redmine version 3.0.x? I do not receive this information unless, as mentionned above, it is set as a public project. I tried vilppuvuorinen suggestion of adding Anonymous Users group as a member to the private project but it does not have any effect on the the issue custom field owner-email... Still no luck... It would be great to have a work around for that situation. Any suggestion?

@vilppuvuorinen
Copy link
Contributor

I haven't actually physically tested 3.0.x, but I believe the same errors are present in 2.6.x releases. The tests should be updated to point the latest released versions. As a quick fix I would suggest using a separate project for the issues for now. I would look into this out of interest if my schedule would allow at the moment.

@BRUTEF0RCE
Copy link

Thank you for your quick reply!! By the way, what did you mean by "it will take some fiddling around to break the ACLs just a little." ? Maybe I could try that!

@vilppuvuorinen
Copy link
Contributor

I would suggest taking a look in the unit tests. Creating a test case where one of the projects is set as private and adding an issue though email is attempted. This would provide extremely verbose output about the needed changes. It would also work as a template if it is possible to implement those changes and merge them.

I can't really say if this is possible to perform without crippling the access control.

@BRUTEF0RCE
Copy link

I am not really setup to do this testing with unit tests right now. A separate project is not really an option for me right now neither... Too bad... Did you find anything interesting by the meantime?

@vilppuvuorinen
Copy link
Contributor

Well I ended up looking a clear explanation why this won't work in any easily controllable way.

To provide some control over the email interface there is a treat_user_as_supportclient permission. Email processing is hijacked after the issue is created and the owner-email is populated if issues' author has the treat_user_as_supportclient permission in the target project. The permissions are verified with roles_for_project(project)of Redmine's used model (see the code below). As you can see from the code snippet first step in the function is to get a list of the user's memberships. If no memberships are available at this point the lookup falls back to using using non-member roles.

The problem is that for example User.anonymous.memberships returns always an empty array no matter what memberships are set up.

# Returns user's membership for the given project
  # or nil if the user is not a member of project
  def membership(project)
    project_id = project.is_a?(Project) ? project.id : project

    @membership_by_project_id ||= Hash.new {|h, project_id|
      h[project_id] = memberships.where(:project_id => project_id).first
    }
    @membership_by_project_id[project_id]
  end

[...]

  # Return user's roles for project
  def roles_for_project(project)
    # No role on archived projects
    return [] if project.nil? || project.archived?
    if membership = membership(project)
      membership.roles.dup
    elsif project.is_public?
      project.override_roles(builtin_role)
    else
      []
    end
  end

To work around this modifications would be needed at (currently) line 21 of mail_handler_patch.rb. Changing

if roles.any? {|role| role.allowed_to?(:treat_user_as_supportclient) }

to

if issue.author.type.eql?("AnonymousUser") || roles.any? {|role| role.allowed_to?(:treat_user_as_supportclient) }

However, this would partially break the intended functionality of the check.

@nixmomo
Copy link

nixmomo commented May 14, 2015

This was my issue too.. this fix works perfect with private projects!

10000 thanks and a beer for you :-)

@BRUTEF0RCE
Copy link

Thank you vilppuvuorinen for this work around! It will do the job for now on our side!! :)

Regards

@kaazoo
Copy link

kaazoo commented Jul 16, 2015

The workaround also helps in my case. Thanks ;)

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

6 participants