Files
pathfinder/app/Lib/Logging/Handler/AbstractRallyWebhookHandler.php
Sam 15a0fcee0f Bug fixes for v2.2.0 (#81)
* util.js: decode shipname for popover

* Bump version to 2.2.0

* Bump react/promise-stream from 1.2.0 to 1.3.0 (#46)

Bumps [react/promise-stream](https://github.com/reactphp/promise-stream) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/reactphp/promise-stream/releases)
- [Changelog](https://github.com/reactphp/promise-stream/blob/master/CHANGELOG.md)
- [Commits](https://github.com/reactphp/promise-stream/compare/v1.2.0...v1.3.0)

---
updated-dependencies:
- dependency-name: react/promise-stream
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump monolog/monolog from 2.3.4 to 2.3.5 (#37)

Bumps [monolog/monolog](https://github.com/Seldaek/monolog) from 2.3.4 to 2.3.5.
- [Release notes](https://github.com/Seldaek/monolog/releases)
- [Changelog](https://github.com/Seldaek/monolog/blob/main/CHANGELOG.md)
- [Commits](https://github.com/Seldaek/monolog/compare/2.3.4...2.3.5)

---
updated-dependencies:
- dependency-name: monolog/monolog
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sam <30859143+samoneilll@users.noreply.github.com>

* Bump slash from 3.0.0 to 4.0.0 (#34)

Bumps [slash](https://github.com/sindresorhus/slash) from 3.0.0 to 4.0.0.
- [Release notes](https://github.com/sindresorhus/slash/releases)
- [Commits](https://github.com/sindresorhus/slash/compare/v3.0.0...v4.0.0)

---
updated-dependencies:
- dependency-name: slash
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump gulp-imagemin from 7.1.0 to 8.0.0 (#33)

Bumps [gulp-imagemin](https://github.com/sindresorhus/gulp-imagemin) from 7.1.0 to 8.0.0.
- [Release notes](https://github.com/sindresorhus/gulp-imagemin/releases)
- [Commits](https://github.com/sindresorhus/gulp-imagemin/compare/v7.1.0...v8.0.0)

---
updated-dependencies:
- dependency-name: gulp-imagemin
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump gulp-sourcemaps from 2.6.5 to 3.0.0 (#32)

Bumps [gulp-sourcemaps](https://github.com/gulp-sourcemaps/gulp-sourcemaps) from 2.6.5 to 3.0.0.
- [Release notes](https://github.com/gulp-sourcemaps/gulp-sourcemaps/releases)
- [Commits](https://github.com/gulp-sourcemaps/gulp-sourcemaps/compare/v2.6.5...v3.0.0)

---
updated-dependencies:
- dependency-name: gulp-sourcemaps
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump gulp-filter from 6.0.0 to 7.0.0 (#30)

Bumps [gulp-filter](https://github.com/sindresorhus/gulp-filter) from 6.0.0 to 7.0.0.
- [Release notes](https://github.com/sindresorhus/gulp-filter/releases)
- [Commits](https://github.com/sindresorhus/gulp-filter/compare/v6.0.0...v7.0.0)

---
updated-dependencies:
- dependency-name: gulp-filter
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump gulp-autoprefixer from 7.0.1 to 8.0.0 (#31)

Bumps [gulp-autoprefixer](https://github.com/sindresorhus/gulp-autoprefixer) from 7.0.1 to 8.0.0.
- [Release notes](https://github.com/sindresorhus/gulp-autoprefixer/releases)
- [Commits](https://github.com/sindresorhus/gulp-autoprefixer/compare/v7.0.1...v8.0.0)

---
updated-dependencies:
- dependency-name: gulp-autoprefixer
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sam <30859143+samoneilll@users.noreply.github.com>

* Bump cache/filesystem-adapter from 1.0.0 to 1.1.0 (#29)

Bumps [cache/filesystem-adapter](https://github.com/php-cache/filesystem-adapter) from 1.0.0 to 1.1.0.
- [Release notes](https://github.com/php-cache/filesystem-adapter/releases)
- [Changelog](https://github.com/php-cache/filesystem-adapter/blob/master/Changelog.md)
- [Commits](https://github.com/php-cache/filesystem-adapter/compare/1.0.0...1.1.0)

---
updated-dependencies:
- dependency-name: cache/filesystem-adapter
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sam <30859143+samoneilll@users.noreply.github.com>

* Bump react/socket from 1.3.0 to 1.9.0 (#27)

Bumps [react/socket](https://github.com/reactphp/socket) from 1.3.0 to 1.9.0.
- [Release notes](https://github.com/reactphp/socket/releases)
- [Changelog](https://github.com/reactphp/socket/blob/master/CHANGELOG.md)
- [Commits](https://github.com/reactphp/socket/compare/v1.3.0...v1.9.0)

---
updated-dependencies:
- dependency-name: react/socket
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sam <30859143+samoneilll@users.noreply.github.com>

* Bump cache/redis-adapter from 1.0.0 to 1.1.0 (#28)

Bumps [cache/redis-adapter](https://github.com/php-cache/redis-adapter) from 1.0.0 to 1.1.0.
- [Release notes](https://github.com/php-cache/redis-adapter/releases)
- [Changelog](https://github.com/php-cache/redis-adapter/blob/master/Changelog.md)
- [Commits](https://github.com/php-cache/redis-adapter/compare/1.0.0...1.1.0)

---
updated-dependencies:
- dependency-name: cache/redis-adapter
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sam <30859143+samoneilll@users.noreply.github.com>

* requirements.ini: bumps memory requirement to 256M

* package.json: downgrades imagemin to 7.1.0

* package-lock.json: resolves npm-audit dependency warnings

* AbstractRallyWebhookHandler.php: Convert Truesec value to str

* CorporationModel.php: resets corporationStructureModel instance to avoid overwriting the same record

* Updates wormhole minimum jump mass

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-12-02 11:28:03 +01:00

155 lines
6.5 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: Exodus 4D
* Date: 17.11.2018
* Time: 10:09
*/
namespace Exodus4D\Pathfinder\Lib\Logging\Handler;
use League\HTMLToMarkdown\HtmlConverter;
use Exodus4D\Pathfinder\Lib\Util;
abstract class AbstractRallyWebhookHandler extends AbstractWebhookHandler {
/**
* @param array $record
* @return array
*/
protected function getSlackData(array $record) : array {
$postData = parent::getSlackData($record);
$tag = (string)$record['context']['tag'];
$timestamp = (int)$record['datetime']->getTimestamp();
$text = '';
if (
$this->useAttachment &&
!empty( $attachmentsData = $record['context']['data'])
){
// convert non grouped data (associative array) to multi dimensional (sequential) array
// -> see "group" records
$attachmentsData = Util::is_assoc($attachmentsData) ? [$attachmentsData] : $attachmentsData;
$thumbData = (array)$record['extra']['thumb'];
$postData['attachments'] = [];
foreach($attachmentsData as $attachmentData){
$characterData = (array)$attachmentData['character'];
$text = 'No Title';
if( !empty($attachmentData['formatted']) ){
$text = $attachmentData['formatted'];
}
$attachment = [
'title' => !empty($attachmentData['main']['message']) ? 'Message' : '',
//'pretext' => '',
'text' => !empty($attachmentData['main']['message']) ? sprintf('```%s```', $attachmentData['main']['message']) : '',
'fallback' => !empty($attachmentData['main']['message']) ? $attachmentData['main']['message'] : 'No Fallback',
'color' => $this->getAttachmentColor($tag),
'fields' => [],
'mrkdwn_in' => ['fields', 'text'],
'footer' => 'Pathfinder API',
//'footer_icon'=> '',
'ts' => $timestamp
];
$attachment = $this->setAuthor($attachment, $characterData);
$attachment = $this->setThumb($attachment, $thumbData);
// set 'field' array ----------------------------------------------------------------------------------
if ($this->includeContext) {
if(!empty($objectData = $attachmentData['object'])){
if(!empty($objectData['objAlias'])){
// System alias
$attachment['fields'][] = $this->generateAttachmentField('Alias', $objectData['objAlias']);
}
if(!empty($objectData['objName'])){
// System name
$attachment['fields'][] = $this->generateAttachmentField('System', $objectData['objName']);
}
if(!empty($objectData['objRegion'])){
// System region
$attachment['fields'][] = $this->generateAttachmentField('Region', $objectData['objRegion']);
}
if(isset($objectData['objIsWormhole'])){
// Is wormhole
$attachment['fields'][] = $this->generateAttachmentField('Wormhole', $objectData['objIsWormhole'] ? 'Yes' : 'No');
}
if(!empty($objectData['objSecurity'])){
// System security
$attachment['fields'][] = $this->generateAttachmentField('Security', $objectData['objSecurity']);
}
if(!empty($objectData['objEffect'])){
// System effect
$attachment['fields'][] = $this->generateAttachmentField('Effect', $objectData['objEffect']);
}
if(!empty($objectData['objTrueSec'])){
// System trueSec
$attachment['fields'][] = $this->generateAttachmentField('TrueSec', strval($objectData['objTrueSec']));
}
if(!empty($objectData['objCountPlanets'])){
// System planet count
$attachment['fields'][] = $this->generateAttachmentField('Planets', $objectData['objCountPlanets']);
}
if(!empty($objectData['objDescription'])){
// System description
$attachment['fields'][] = $this->generateAttachmentField('System description', '```' . $this->htmlToMarkdown($objectData['objDescription']) . '```', false, false);
}
if(!empty($objectData['objUrl'])){
// System deeeplink
$attachment['fields'][] = $this->generateAttachmentField('', $objectData['objUrl'] , false, false);
}
}
}
if($this->includeExtra){
if(!empty($record['extra']['path'])){
$attachment['fields'][] = $this->generateAttachmentField('Path', $record['extra']['path'], true);
}
if(!empty($tag)){
$attachment['fields'][] = $this->generateAttachmentField('Tag', $tag, true);
}
if(!empty($record['level_name'])){
$attachment['fields'][] = $this->generateAttachmentField('Level', $record['level_name'], true);
}
if(!empty($record['extra']['ip'])){
$attachment['fields'][] = $this->generateAttachmentField('IP', $record['extra']['ip'], true);
}
}
$postData['attachments'][] = $attachment;
}
}
$postData['text'] = empty($text) ? $postData['text'] : $text;
return $postData;
}
/**
* convert $html into Markdown
* @param $html
* @return string
*/
protected function htmlToMarkdown($html){
$converter = new HtmlConverter();
$converter->getConfig()->setOption('strip_tags', true);
return $converter->convert($html);
}
}