Download & Extend

Problems with Token integration with Rules

Project:Statuses (Social Microblog)
Version:7.x-1.x-dev
Component:Integrations
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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.

Comments

#1

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.

#2

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.

#3

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.

#4

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.

#5

Category:support request» bug report

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.

#6

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

#7

Status:active» needs work

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).

AttachmentSize
statuses-rules-load-comment-1693620-7.patch 1.4 KB

#8

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

#9

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

#10

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.

#11

Assigned to:Anonymous» mathankumarc

I'm started on this :)

#12

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 :)

AttachmentSize
rules-integration-issue-1693620-12.patch 2.31 KB

#13

Status:needs work» needs review

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]"
        }
      }
    ]
  }
}
AttachmentSize
rules-integration-issue-1693620-13.patch 3.13 KB

#14

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).

#15

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.

#16

Status:needs review» fixed

Committed a fix to dev.

#17

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.

#18

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

#19

Status:fixed» closed (fixed)

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

#20

Assigned to:mathankumarc» Anonymous