1

I am using Rules, Message, Message Notify and Flag modules. I added a message to the activity stream when user flags a node as "Favorite".

My problem is I am getting notification, but the node that was flagged seems to be missing from the message entity. Please guide for the steps, or where I may be wrong

UPDATE: Adding rules in export format for better understanding and reference. In mail being send through rule, every token is working perfectly, but not in message added to activity stream.

{ "rules_user_likes_a_node" : {
    "LABEL" : "User likes a node",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "flag" ],
    "ON" : { "flag_flagged_group_flag" : [] },
    "DO" : [
      { "variable_add" : {
          "USING" : { "type" : "node", "value" : [ "flagged-node" ] },
          "PROVIDE" : { "variable_added" : { "node" : "Added variable" } }
        }
      },
      { "mail" : {
          "to" : [ "flagged-node:author:mail" ],
          "subject" : "[flagged-node:content-type] [flagged-node:title] est aim\u00e9",
          "message" : "Hello [flagged-node:author:name],\r\n\r\n\r\n[flagging-user:name] loved[flagged-node:content-type] [flagged-node:title]",
          "language" : [ "" ]
        }
      },
      { "entity_create" : {
          "USING" : {
            "type" : "message",
            "param_type" : "commons_activity_streams_user_likes_a_node",
            "param_user" : [ "site:current-user" ]
          },
          "PROVIDE" : { "entity_created" : { "message" : "Created entity" } }
        }
      },
      { "data_set" : { "data" : [ "flagged-node" ], "value" : [ "flagged-node" ] } }
    ]
  }
}
0

1 Answer 1

3

Actually, I tried "Set a data value" action, but was setting wrong variables in it. Using it right way and adding "Save entity" action (I think without this also it may work fine now) worked for me.

Following is the rules' export format in case someone need it in future:

{ "rules_user_likes_a_node" : {
    "LABEL" : "User likes a node",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "flag" ],
    "ON" : { "flag_flagged_group_flag" : [] },
    "DO" : [
      { "variable_add" : {
          "USING" : { "type" : "node", "value" : [ "flagged-node" ] },
          "PROVIDE" : { "variable_added" : { "node" : "Added variable" } }
        }
      },
  { "mail" : {
      "to" : [ "flagged-node:author:mail" ],
      "subject" : "[flagged-node:content-type] [flagged-node:title] est aim\u00e9",
      "message" : "Hello [flagged-node:author:name],\r\n\r\n\r\n[flagging-user:name] loved[flagged-node:content-type] [flagged-node:title]",
      "language" : [ "" ]
    }
  },
      { "entity_create" : {
          "USING" : {
            "type" : "message",
            "param_type" : "commons_activity_streams_user_likes_a_node",
            "param_user" : [ "site:current-user" ]
          },
          "PROVIDE" : { "entity_created" : { "message" : "Created entity" } }
        }
      },
      { "data_set" : {
          "data" : [ "message:field-target-nodes:0" ],
          "value" : [ "flagged-node" ]
        }
      },
      { "entity_save" : { "data" : [ "message" ] } }
    ]
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.