bytrislasis
Member
Hello everyone,
I want to send an alert to the user with the ID 1 when our members initiate a withdrawal request to their Ethereum addresses.
Here's what I've done so far:I defined a type named wallet_transfer in the content type section of the admin panel. You can see it in the image below.
Then, I defined an entity.
I created a directory named Alert in the root directory of my plugin and added the following codes inside.
I'm sending the alert notification as below:
I also created a template with the name alert_wallet_transfer_withdraw.
I do receive the notification, but when I click on it, the content appears empty. I'd appreciate any assistance in identifying where I might be going wrong.
Empty alert loading...
Entity File
Database xf_alert
I want to send an alert to the user with the ID 1 when our members initiate a withdrawal request to their Ethereum addresses.
Here's what I've done so far:I defined a type named wallet_transfer in the content type section of the admin panel. You can see it in the image below.
Then, I defined an entity.
I created a directory named Alert in the root directory of my plugin and added the following codes inside.
PHP:
<?php
namespace SatoshiTURK\Wallet\Alert;
use XF\Alert\AbstractHandler;
class WalletTransfer extends AbstractHandler
{
public function getEntityWith(): array
{
return ['transfer_id', 'user_id','User'];
}
public function getOptOutActions(): array
{
return ['withdraw'];
}
}
I'm sending the alert notification as below:
PHP:
// ID'si 1 olan kullanıcıya bildirim gönder
$receiver = $this->em()->find('XF:User', 1);
if ($receiver) {
$sender = \XF::finder('XF:User')->where('user_id', 10)->fetchOne();
$alertRepo = $this->repository('XF:UserAlert');
$alertRepo->alert(
$receiver,
$sender->user_id,
$sender->username,
'wallet_transfer',
$newTransfer->transfer_id,
'withdraw',
["amount" => $input['withdraw_amount'], "address" => $input['withdraw_address'], "status" => "pending"]
);
}
I also created a template with the name alert_wallet_transfer_withdraw.
I do receive the notification, but when I click on it, the content appears empty. I'd appreciate any assistance in identifying where I might be going wrong.
Empty alert loading...
Entity File
PHP:
<?php
namespace SatoshiTURK\Wallet\Entity;
use XF\Mvc\Entity\Entity;
use XF\Mvc\Entity\Structure;
class WalletTransfer extends Entity
{
public static function getStructure(Structure $structure)
{
$structure->table = 'xf_satoshiturk_wallet_transfers';
$structure->shortName = 'SatoshiTURK\Wallet:WalletTransfer';
$structure->contentType = 'wallet_transfer';
$structure->primaryKey = 'transfer_id';
$structure->columns = [
'transfer_id' => ['type' => self::UINT, 'autoIncrement' => true],
'user_id' => ['type' => self::UINT, 'required' => true],
'amount' => ['type' => self::FLOAT, 'required' => true],
'ethereum_address' => ['type' => self::STR, 'maxLength' => 255, 'required' => true],
'status' => ['type' => self::STR, 'default' => 'pending'],
'created_at' => ['type' => self::UINT, 'default' => \XF::$time],
'updated_at' => ['type' => self::UINT, 'default' => \XF::$time]
];
$structure->relations = [
'User' => [
'entity' => 'XF:User',
'type' => self::TO_ONE,
'conditions' => 'user_id',
'primary' => true
],
];
return $structure;
}
public function whereIds(array $ids)
{
return $this->finder('SatoshiTURK\Wallet:WalletTransfer')->where('transfer_id', $ids);
}
public function with()
{
return $this->with('User');
}
}
Database xf_alert
Last edited: