Hi there,

In #1255280: Document alternative to Notifications integration, you mentioned that it is possible to create a Rule to send an email to the sender of a status when someone comments on the status – but that in order to do so, it is "probably necessary to load the status object to get access to the sender's email address."

Can you explain how you are loading the status object? I see the Action to "Load a status", but no way to get a data selector I can use to get the ID to pass to that Action.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mrwhizkid’s picture

I've been trying to figure this out too:

When you use the action 'load a status id', these are the only data selectors available:

SELECTOR LABEL DESCRIPTION
site:current-user:uid User ID The unique ID of the user account.
site:current-user:roles: User roles The roles of the user.
site:current-user:status Status Whether the user is active or blocked.

Not sure how to get the status ID.

IceCreamYou’s picture

There should be tokens for the comment being created, one of which should be the status ID. If tokens for the comment being created are not there, that is probably a bug. However, I can only respond to bug reports against the development build until there is a stable release.

mrwhizkid’s picture

Version: 7.x-1.0-unstable4 » 7.x-1.x-dev

Is it OK then for me to change this status to the development build? That is actually what I am using now and I am having the same problem.

No tokens for the status ID when trying to load a status from an event of saving a new comment.

venutip’s picture

A closer look reveals that I am using the dev version as well. Hard to tell since there's no version number in the .info file.

IceCreamYou’s picture

Category: support » bug

Is it OK then for me to change this status to the development build?

Of course

Hard to tell since there's no version number in the .info file.

The only reason you wouldn't have a version number in the .info file is if you pulled the files from git. The drupal.org packaging script puts a block like this into every packaged release:

; Information added by drupal.org packaging script on 2012-07-17
version = "7.x-1.0-unstable4+73-dev"
core = "7.x"
project = "statuses"
datestamp = "1342486432"

The version should also appear at admin/modules.

venutip’s picture

Yeah, got it from git so no version number in .info or at /modules.

IceCreamYou’s picture

Status: Active » Needs work
FileSize
1.4 KB

The problem here seems to be that Statuses offers a "Load a status" action, but Rules now expects you to use its "Add a variable" action instead. Statuses aren't currently available as a type of variable to add, and the "Load a status" action doesn't have tokens available to it. It's not immediately obvious to me why there are no tokens available to the "Load a status" action, although there are some things wrong with the way the action is specified (untested patch attached).

craigritchie’s picture

Apologies -- to be clear, what does this patch do, if I apply it?

IceCreamYou’s picture

Might clear up some errors, but otherwise pretty much nothing right now :)

IceCreamYou’s picture

Title: Create a Rule to send an email to the sender of a status on comment » Problems with Token integration with Rules

Renaming to more accurately reflect the root issue, since it is causing problems for several different Rule configurations.

mathankumarc’s picture

Assigned: Unassigned » mathankumarc

I'm started on this :)

mathankumarc’s picture

Ah Found out the problem.

Here also the problem is statuses is not an entity, however rules considers the statuses as entity. Rules module provided additional options to implement rules on non entity.

Attached a partial patch, still its need cleanup/fixes.

Note:
Actually the rules integration is broken, there is no problem with token integration :(

To identify this one point, explored lot resources and learned many things :)

mathankumarc’s picture

Status: Needs work » Needs review
FileSize
3.13 KB

Here is the complete patch.

Testers are welcome. Don't forget to monitor the log messages while testing.

Sample rule for sending mail to the sender of the status when someone commented on it,

{ "rules_user_commented_on_status" : {
    "LABEL" : "User commented on a status",
    "PLUGIN" : "reaction rule",
    "TAGS" : [ "Statuses" ],
    "REQUIRES" : [ "fbss_rules", "rules", "fbss_comments_rules" ],
    "ON" : [ "fbss_comments_save" ],
    "DO" : [
      { "fbss_rules_load_action" : {
          "USING" : { "sid" : [ "comment:sid" ] },
          "PROVIDE" : { "status_loaded" : { "status_loaded" : "Loaded status" } }
        }
      },
      { "mail" : {
          "to" : "[status-loaded:sender:mail]",
          "subject" : "[comment:commenter:name] commented on your status",
          "message" : "Hi [status-loaded:sender:name],\r\n\r\n[comment:commenter:name] commented on your status [status-loaded:message-formatted]\r\n\r\n\r\nRegards,\r\n[site:name]"
        }
      }
    ]
  }
}
IceCreamYou’s picture

Haven't tested, but looks good to me -- in any case it's better than what we have now. ;) If you think this issue is basically resolved, feel free to commit and address any followup problems in separate issue(s).

mathankumarc’s picture

I thought waiting until someone test this and give a report.

Any volunteers?

By the way, Sorry for the very late replay, due to my health challenges unable to look into the issue queue for past 3 weeks.

mathankumarc’s picture

Status: Needs review » Fixed

Committed a fix to dev.

eidoscom’s picture

Hi mathankumark, you say that is commited but non updated dev version on the page. Where can we download the new dev ??

Thanks a lot and sorry for reopen the fixed issue.

IceCreamYou’s picture

Dev builds automatically regenerate every 12 hours. If you want it sooner than that, pull it down from git.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mathankumarc’s picture

Assigned: mathankumarc » Unassigned
Pierre.Vriens’s picture

Issue summary: View changes

Just in case anybody is still interested in this topic, have a look at the Rules example included at the end of the answer to How to add missing data selector in "Create new entity" rules action?.

The rule shown there, was inspired by what's in comment #13 here. And instead of sending an eMail ("to" the "sender"-token), it does some extra Rules Actions to fetch a user entity (by property), and then uses that to target a message to that user (using the Message module ... which expects a REAL entity). A bit of Rules-hitech, but it works like a charm, starting from the status-loaded:sender as provided by the patch in #13.

ugintl’s picture

I have tested the solution provided in #21

It works