Defect #6082


acts_as_event email key

Added by Felix Schäfer almost 13 years ago. Updated over 2 years ago.

Activity view
Target version:
Start date:
Due date:
% Done:


Estimated time:
Affected version:


When gravatars are enabled, the activity view tries to show the gravatar by passing a user object to the avatar method. While this works for all events that have local users, the changeset model/event can't always create a local user object for the changeset while still having the email of the user that generated this changeset.

Concrete use-case: I have a git repository in which I have cherry-picked 2 revisions from a user not member of my redmine installation, in this case the changeset retains the author not as a user object, but as a string "name <email>" (very much like git presents it), the changeset object only presents the "name" as the author (see source:/trunk/app/models/changeset.rb#L68). While this is correct behavior for places just polling event_author for a name, the avatar won't get the email address from it, though that information is present. I've changed the activity view to try to use committer (the whole "name <email>", which avatar parses corectly) if the "normal" way doesn't yield an avatar, the following line source:trunk/app/views/projects/activity.rhtml#L10

<%= avatar(e.event_author, :size => "24") if e.respond_to?(:event_author) %>

to read:

<%= (avatar(e.event_author, :size => "24") if e.respond_to?(:event_author)) or (avatar(e.committer, :size => "24") if e.respond_to?(:committer)) %>

This solves the problem for changesets, but will not solve it for the generic case.

I see 2 options here to deal with that: either extend acts_as_event to also provide a method/an interface to query the author's email address (but that feels somewhat kludgy), or mock a (temporary) user object with the information we have (basically the name for the to_s method and the email address for email) to provide the same interface as for "local users". This might break further along down the way though if anything polling the events expects to receive a full user object but only gets one with a very limited interface.


bugs_ruby-lang_org-activity.png (251 KB) bugs_ruby-lang_org-activity.png Go MAEDA, 2020-12-07 07:20
6082.patch (4.52 KB) 6082.patch Yuichi HARADA, 2020-12-22 05:34

Also available in: Atom PDF