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

Output of webhooks appear incorrectly in chat #11669

Closed
luckenbach opened this issue Aug 3, 2018 · 5 comments · Fixed by #11740
Closed

Output of webhooks appear incorrectly in chat #11669

luckenbach opened this issue Aug 3, 2018 · 5 comments · Fixed by #11740

Comments

@luckenbach
Copy link

Description:

Formatting of attachments is appearing odd in desktop / web apps.

Steps to reproduce:

  1. Create a webhook
  2. POST data to webhook

Expected behavior:

Webook's fields should appears stacked and not horizontal

Phone appears normal
image

Actual behavior:

image

Server Setup Information:

  • Version of Rocket.Chat Server: 0.68.1
  • Operating System: Linux/k8s
  • Deployment Method: docker
  • Number of Running Instances: 1
  • DB Replicaset Oplog: Disabled
  • NodeJS Version: v8.11.3
  • MongoDB Version: 3.4.7

Additional context

Relevant logs:

@kaiiiiiiiii
Copy link
Contributor

For testing purposes, could you please provide the Webhook payload that is sent to the chat and your custom webhook script (if used)?

@luckenbach
Copy link
Author

luckenbach commented Aug 6, 2018

Payload:

    "schemaId": "Microsoft.Insights/activityLogs",
    "data": {
        "status": "Activated",
        "context": {
            "activityLog": {
                "authorization": {
                    "action": "Microsoft.Compute/virtualMachines/delete",
                    "scope": "/subscriptions/11/resourceGroups/kafka-staging/providers/Microsoft.Compute/virtualMachines/testmachine"
                },
                "channels": "Operation",
                "caller": "c",
                "correlationId": "f",
                "description": "",
                "eventSource": "Administrative",
                "eventTimestamp": "2018-07-31T18:10:04.8374492+00:00",
                "httpRequest": "{\"clientRequestId\":\"\",\"clientIpAddress\":\"123\",\"method\":\"DELETE\"}",
                "eventDataId": "123",
                "level": "Informational",
                "operationName": "Microsoft.Compute/virtualMachines/delete",
                "operationId": "123",
                "resourceId": "/subscriptions/123/resourceGroups/kafka-staging/providers/Microsoft.Compute/virtualMachines/testmachine",
                "resourceGroupName": "kafka-staging",
                "resourceProviderName": "Microsoft.Compute",
                "status": "Started",
                "subStatus": "",
                "subscriptionId": "123",
                "submissionTimestamp": "2018-07-31T18:10:23.1631897+00:00",
                "resourceType": "Microsoft.Compute/virtualMachines"
            }
        },
        "properties": {}
    }
}

Webhook:

  process_incoming_request({ request }) {
    // console is a global helper to improve debug
    console.log(request.content.data.context)


    var alertColor = "good";

    // if(request.content.status === "Resolved"){ alertColor = "good"; }
    // else if (request.content.status === "Activated") { alertColor = "danger"; }
    var ad = request.content.data.context.activityLog;

    return {
      content:{
        text: "Azure Activity Notification",
        attachments: [{
          title: ad.operationName,
          pretext: ad.description,
          color: alertColor,
          fields: [
            {
              title: "Resource",
              value: ad.resourceId + '\n'
            },
            {
              title: "Event Type",
              value: ad.eventSource
            },
            {
              title: "Level",
              value: ad.level
            },
           {
              title: "Operation",
              value: ad.operationName
            },
            {
              title: "Status",
              value: ad.status
            }
          ]
        }]
       }
    };

    return {
       error: {
         success: false,
         message: 'Error'
       }
    };
  }
}

@kaiiiiiiiii
Copy link
Contributor

kaiiiiiiiii commented Aug 6, 2018

By default every attachment field is short and allows another field to be right next to it. If you don’t want that behavior you can simply add "short": false to a field. Adding that field parameter should do the magic for you :)

@luckenbach
Copy link
Author

short: True or False doesn't seem to effect this

@graywolf336
Copy link
Contributor

This will be closed/fixed by #11740

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

Successfully merging a pull request may close this issue.

3 participants