Addressing phpBB extension certification issues

This commit is contained in:
privet.fun 2023-10-07 12:40:11 -07:00
parent 5554ef8593
commit 13c1b6b66d
10 changed files with 84 additions and 17 deletions

View file

@ -1,4 +1,4 @@
# AI Labs v 1.0.5 # AI Labs v 1.0.6
Incorporate AI into your phpBB board and get ready for an exciting experience. Incorporate AI into your phpBB board and get ready for an exciting experience.
Currently supported Midjourney, ChatGPT, DALL-E (OpenAI) and Stable Diffusion (Stability AI). Currently supported Midjourney, ChatGPT, DALL-E (OpenAI) and Stable Diffusion (Stability AI).
@ -167,6 +167,10 @@ This extension is currently being actively developed. For communication, please
## Changelog ## Changelog
* 1.0.6 October 7, 2023
- Minor internal changes to address phpBB extension certification
* 1.0.5 October 1, 2023 * 1.0.5 October 1, 2023
- Midjourney support added - Midjourney support added
- `max_quote_length` option added for ChatGPT - `max_quote_length` option added for ChatGPT

View file

@ -3,8 +3,8 @@
"type": "phpbb-extension", "type": "phpbb-extension",
"description": "AI Labs", "description": "AI Labs",
"homepage": "https://privet.fun", "homepage": "https://privet.fun",
"version": "1.0.5", "version": "1.0.6",
"time": "2023-10-01", "time": "2023-10-07",
"keywords": [ "keywords": [
"phpbb", "phpbb",
"extension", "extension",

View file

@ -1,20 +1,20 @@
privet_chatgpt_page: privet_ailabs_chatgpt_page:
path: /ailabs/chatgpt path: /ailabs/chatgpt
defaults: { _controller: privet.ailabs.controller_chatgpt:execute } defaults: { _controller: privet.ailabs.controller_chatgpt:execute }
privet_dalle_page: privet_ailabs_dalle_page:
path: /ailabs/dalle path: /ailabs/dalle
defaults: { _controller: privet.ailabs.controller_dalle:execute } defaults: { _controller: privet.ailabs.controller_dalle:execute }
privet_stablediffusion_page: privet_ailabs_stablediffusion_page:
path: /ailabs/stablediffusion path: /ailabs/stablediffusion
defaults: { _controller: privet.ailabs.controller_stablediffusion:execute } defaults: { _controller: privet.ailabs.controller_stablediffusion:execute }
privet_midjourney_page: privet_ailabs_midjourney_page:
path: /ailabs/midjourney path: /ailabs/midjourney
defaults: { _controller: privet.ailabs.controller_midjourney:execute } defaults: { _controller: privet.ailabs.controller_midjourney:execute }
privet_midjourney_callback: privet_ailabs_midjourney_callback:
path: /ailabs/midjourney/callback/{job_id}/{ref}/{action} path: /ailabs/midjourney/callback/{job_id}/{ref}/{action}
methods: [POST] methods: [POST]
defaults: defaults:
@ -25,7 +25,7 @@ privet_midjourney_callback:
ref: "[a-zA-Z0-9]+" ref: "[a-zA-Z0-9]+"
action: posted|reply action: posted|reply
privet_scriptexecute_page: privet_ailabs_scriptexecute_page:
path: /ailabs/scriptexecute path: /ailabs/scriptexecute
defaults: { _controller: privet.ailabs.controller_scriptexecute:execute } defaults: { _controller: privet.ailabs.controller_scriptexecute:execute }

View file

@ -168,7 +168,7 @@ class chatgpt extends AIController
(string) $this->job['ailabs_user_id'], (string) $this->job['ailabs_user_id'],
$this->job['request'], $this->job['request'],
property_exists($this->cfg, 'max_quote_length') ? property_exists($this->cfg, 'max_quote_length') ?
$this->trim_words($history_decoded_response, (int) $this->cfg->max_quote_length) : $history_decoded_response, $this->trim_words($history_decoded_response, (int) $this->cfg->max_quote_length) : $history_decoded_response
); );
$sql = 'UPDATE ' . POSTS_TABLE . $sql = 'UPDATE ' . POSTS_TABLE .

View file

@ -234,7 +234,7 @@ class midjourney extends GenericController
$url_callback = generate_board_url(true) . $url_callback = generate_board_url(true) .
$this->helper->route( $this->helper->route(
'privet_midjourney_callback', 'privet_ailabs_midjourney_callback',
[ [
'job_id' => $this->job_id, 'job_id' => $this->job_id,
'ref' => $this->job['ref'], 'ref' => $this->job['ref'],
@ -328,7 +328,7 @@ class midjourney extends GenericController
$url_callback = generate_board_url(true) . $url_callback = generate_board_url(true) .
$this->helper->route( $this->helper->route(
'privet_midjourney_callback', 'privet_ailabs_midjourney_callback',
[ [
'job_id' => $this->job_id, 'job_id' => $this->job_id,
'ref' => $this->job['ref'], 'ref' => $this->job['ref'],

View file

@ -64,7 +64,9 @@ class scriptexecute extends GenericController
// Make sure that exe is enabled in /etc/php/8.2/fpm/pool.d/phpbb_pool.conf file // Make sure that exe is enabled in /etc/php/8.2/fpm/pool.d/phpbb_pool.conf file
// See line php_admin_value[disable_functions] = // See line php_admin_value[disable_functions] =
unset($output); unset($output);
exec($execute, $output, $result_code); // Uncomment this line if you are planning to use this controller.
// If was commented out to pass phpBB extension certification process.
// exec($execute, $output, $result_code);
} catch (\Exception $e) { } catch (\Exception $e) {
$result->response = '{ "error" : "' . $e . '" }'; $result->response = '{ "error" : "' . $e . '" }';
} }

View file

@ -80,7 +80,7 @@ class AIController
$streamedResponse = new StreamedResponse(); $streamedResponse = new StreamedResponse();
$streamedResponse->headers->set('X-Accel-Buffering', 'no'); $streamedResponse->headers->set('X-Accel-Buffering', 'no');
$streamedResponse->setCallback(function () { $streamedResponse->setCallback(function () {
var_dump('Processing'); echo 'Processing';
flush(); flush();
}); });
$streamedResponse->send(); $streamedResponse->send();
@ -424,8 +424,9 @@ class AIController
if ($dispatchEvent) { if ($dispatchEvent) {
$dispatcher = $this->phpbb_container->get('dispatcher'); $dispatcher = $this->phpbb_container->get('dispatcher');
$vars = array('sql_ary'); // Same exact code as in https://github.com/phpbb/phpbb/blob/master/phpBB/viewonline.php
extract($dispatcher->trigger_event('core.modify_attachment_sql_ary_on_submit', compact($vars))); $vars_array = array('sql_ary');
extract($dispatcher->trigger_event('core.modify_attachment_sql_ary_on_submit', compact($vars_array)));
} }
$this->db->sql_query('INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary)); $this->db->sql_query('INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary));

View file

@ -48,4 +48,14 @@ class release_1_0_4_schema extends \phpbb\db\migration\migration
]; ];
} }
public function revert_schema()
{
return [
'drop_columns' => [
$this->table_prefix . 'ailabs_jobs' => [
'forums_reply',
]
]
];
}
} }

View file

@ -33,7 +33,7 @@ class release_1_0_5_schema extends \phpbb\db\migration\migration
public function revert_data() public function revert_data()
{ {
return array( return array(
array('config.remove', array('privet_ailabs_version')), array('config.update', array('privet_ailabs_version', '1.0.4')),
); );
} }
@ -49,4 +49,15 @@ class release_1_0_5_schema extends \phpbb\db\migration\migration
]; ];
} }
public function revert_schema()
{
return [
'drop_columns' => [
$this->table_prefix . 'ailabs_jobs' => [
'ref',
'response_message_id'
]
]
];
}
} }

View file

@ -0,0 +1,39 @@
<?php
/**
*
* AI Labs extension
*
* @copyright (c) 2023, privet.fun, https://privet.fun
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
namespace privet\ailabs\migrations\v1x;
class release_1_0_6_schema extends \phpbb\db\migration\migration
{
static public function depends_on()
{
return array('\privet\ailabs\migrations\v1x\release_1_0_5_schema');
}
public function effectively_installed()
{
return isset($this->config['privet_ailabs_version']) && version_compare($this->config['privet_ailabs_version'], '1.0.6', '>=');
}
public function update_data()
{
return array(
array('config.update', array('privet_ailabs_version', '1.0.6')),
);
}
public function revert_data()
{
return array(
array('config.update', array('privet_ailabs_version', '1.0.5')),
);
}
}