Skip to content

Discord webhook support per user #59

@sts-ryan-holton

Description

@sts-ryan-holton

I've seen a few webhook questions on here before, but I'm sure the assumption here is a one app, one system approach. What I have is a notifications systems, whereby every customer on my platform needs to integrate Discord, so, the webhook will be different per user, and they'll set it on their profile.

How can I send a notification then to their webhook's url channel?

This is my current routing on my User model to obtain their webhook:

/**
 * Route notifications for the Discord channel.
 */
public function routeNotificationForDiscord($notification)
{
    try {
        $availableIntegration = AvailableIntegration::where('slug', 'discord')
                                                    ->first();

        $userIntegration = UserIntegration::where('user_id', $this->id)
                                          ->where('available_integration_id', $availableIntegration->id)
                                          ->first();

        if (!$userIntegration) {
            return null;
        }

        return $userIntegration->schema->discord_webhook;
    } catch (\Exception $e) { }

    return null;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions