OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)

This commit is contained in:
wangruiguo
2026-09-03 18:49:20 +08:00
commit d647428529
3501 changed files with 1988906 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
<?php
namespace Leantime\Domain\Tickets\Events;
use Leantime\Core\Events\Concerns\InteractsWithEvents;
use Leantime\Core\Events\Contracts\LeantimeEvent;
/**
* Fired when a milestone is created.
*/
final class MilestoneCreated implements LeantimeEvent
{
use InteractsWithEvents;
/**
* @param int|null $milestoneId The created milestone id; null when the emit site doesn't capture it.
* @param string|null $legacyHook TEMPORARY (migration window): the emitting method name —
* pass __FUNCTION__ — used to rebuild the exact historical
* string name this site fired under for plugin listeners.
*/
public function __construct(
public readonly ?int $milestoneId = null,
private readonly ?string $legacyHook = null,
) {}
/**
* The exact historical string name of the emitting site. Remove with the migration window.
*
* @return array<int, string>
*/
public function legacyHooks(): array
{
if ($this->legacyHook === null) {
return [];
}
return ['leantime.domain.tickets.services.tickets.'.$this->legacyHook.'.milestone_created'];
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace Leantime\Domain\Tickets\Events;
use Leantime\Core\Events\Concerns\InteractsWithEvents;
use Leantime\Core\Events\Contracts\LeantimeEvent;
/**
* Fired after a milestone was deleted.
*/
final class MilestoneDeleted implements LeantimeEvent
{
use InteractsWithEvents;
/**
* @param int $milestoneId The deleted milestone id.
* @param string|null $legacyHook TEMPORARY (migration window): the emitting method name —
* pass __FUNCTION__ — used to rebuild the exact historical
* string name this site fired under for plugin listeners.
*/
public function __construct(
public readonly int $milestoneId,
private readonly ?string $legacyHook = null,
) {}
/**
* The exact historical string name of the emitting site. Remove with the migration window.
*
* @return array<int, string>
*/
public function legacyHooks(): array
{
if ($this->legacyHook === null) {
return [];
}
return ['leantime.domain.tickets.services.tickets.'.$this->legacyHook.'.milestone_deleted'];
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace Leantime\Domain\Tickets\Events;
use Leantime\Core\Events\Concerns\InteractsWithEvents;
use Leantime\Core\Events\Contracts\LeantimeEvent;
/**
* Fired after a milestone was updated.
*/
final class MilestoneUpdated implements LeantimeEvent
{
use InteractsWithEvents;
/**
* @param int $milestoneId The updated milestone id.
* @param string|null $legacyHook TEMPORARY (migration window): the emitting method name —
* pass __FUNCTION__ — used to rebuild the exact historical
* string name this site fired under for plugin listeners.
*/
public function __construct(
public readonly int $milestoneId,
private readonly ?string $legacyHook = null,
) {}
/**
* The exact historical string name of the emitting site. Remove with the migration window.
*
* @return array<int, string>
*/
public function legacyHooks(): array
{
if ($this->legacyHook === null) {
return [];
}
return ['leantime.domain.tickets.services.tickets.'.$this->legacyHook.'.milestone_updated'];
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace Leantime\Domain\Tickets\Events;
use Leantime\Core\Events\Concerns\InteractsWithEvents;
use Leantime\Core\Events\Contracts\LeantimeEvent;
/**
* Fired after a project's ticket status labels were saved.
*/
final class StatusLabelsUpdated implements LeantimeEvent
{
use InteractsWithEvents;
/**
* @param int|null $projectId The project whose status labels changed.
* @param string|null $legacyHook TEMPORARY (migration window): the emitting method name —
* pass __FUNCTION__ — used to rebuild the exact historical
* string name this site fired under for plugin listeners.
*/
public function __construct(
public readonly ?int $projectId = null,
private readonly ?string $legacyHook = null,
) {}
/**
* The exact historical string name of the emitting site. Remove with the migration window.
*
* @return array<int, string>
*/
public function legacyHooks(): array
{
if ($this->legacyHook === null) {
return [];
}
return ['leantime.domain.tickets.services.tickets.'.$this->legacyHook.'.statusLabels_updated'];
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace Leantime\Domain\Tickets\Events;
use Leantime\Core\Events\Concerns\InteractsWithEvents;
use Leantime\Core\Events\Contracts\LeantimeEvent;
/**
* Fired after a ticket (including subtasks) was created.
*/
final class TicketCreated implements LeantimeEvent
{
use InteractsWithEvents;
/**
* @param int|null $ticketId The created ticket id; null when the emit site doesn't capture it.
* @param string|null $legacyHook TEMPORARY (migration window): the emitting method name —
* pass __FUNCTION__ — used to rebuild the exact historical
* string name this site fired under for plugin listeners.
*/
public function __construct(
public readonly ?int $ticketId = null,
private readonly ?string $legacyHook = null,
) {}
/**
* The exact historical string name of the emitting site. Remove with the migration window.
*
* @return array<int, string>
*/
public function legacyHooks(): array
{
if ($this->legacyHook === null) {
return [];
}
return ['leantime.domain.tickets.services.tickets.'.$this->legacyHook.'.ticket_created'];
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace Leantime\Domain\Tickets\Events;
use Leantime\Core\Events\Concerns\InteractsWithEvents;
use Leantime\Core\Events\Contracts\LeantimeEvent;
/**
* Fired after a ticket was deleted.
*/
final class TicketDeleted implements LeantimeEvent
{
use InteractsWithEvents;
/**
* @param int $ticketId The deleted ticket id.
* @param string|null $legacyHook TEMPORARY (migration window): the emitting method name —
* pass __FUNCTION__ — used to rebuild the exact historical
* string name this site fired under for plugin listeners.
*/
public function __construct(
public readonly int $ticketId,
private readonly ?string $legacyHook = null,
) {}
/**
* The exact historical string name of the emitting site. Remove with the migration window.
*
* @return array<int, string>
*/
public function legacyHooks(): array
{
if ($this->legacyHook === null) {
return [];
}
return ['leantime.domain.tickets.services.tickets.'.$this->legacyHook.'.ticket_deleted'];
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace Leantime\Domain\Tickets\Events;
use Leantime\Core\Events\Concerns\InteractsWithFilters;
use Leantime\Core\Events\Contracts\LeantimeFilter;
/**
* Filters the grouped ticket list before it is handed to the list/table templates.
* Listeners receive the grouped tickets array and must return it (possibly modified).
*/
final class TicketListFilter implements LeantimeFilter
{
use InteractsWithFilters;
/**
* @param array $tickets The grouped tickets to filter.
* @param string|null $legacyHook TEMPORARY (migration window): the emitting method name —
* pass __FUNCTION__ — used to rebuild the exact historical
* string name this site ran under for plugin listeners.
*/
public function __construct(
public array $tickets,
private readonly ?string $legacyHook = null,
) {}
/**
* The grouped tickets array threaded through the pipeline.
*/
public function payload(): mixed
{
return $this->tickets;
}
/**
* The exact historical string name of the emitting site. Remove with the migration window.
*
* @return array<int, string>
*/
public function legacyHooks(): array
{
if ($this->legacyHook === null) {
return [];
}
return ['leantime.domain.tickets.services.tickets.'.$this->legacyHook.'.filterTickets'];
}
}

View File

@@ -0,0 +1,56 @@
<?php
namespace Leantime\Domain\Tickets\Events;
use Leantime\Core\Events\Concerns\InteractsWithEvents;
use Leantime\Core\Events\Contracts\LeantimeEvent;
/**
* Fired from the repository when a ticket's status column changes (kanban moves,
* inline patches). Carries the legacy payload keys (ticketId/status/action/handler)
* that existing plugin listeners read.
*
* The legacy bridge emits a SUPERSET of each historical payload: the patchTicket site
* historically passed no `handler` key, so its bridged payload now also carries
* `handler => null`. This is additive and safe — consumers read keys by name
* (`$payload['handler'] ?? …`), never by exact key-set/count — and the kanban
* (updateTicketStatus) site, the only live consumer, always carried `handler`.
*/
final class TicketStatusUpdated implements LeantimeEvent
{
use InteractsWithEvents;
/**
* Legacy payload discriminator kept for plugin listeners that switch on it.
*/
public string $action = 'ticketStatusUpdate';
/**
* @param int $ticketId The ticket whose status changed.
* @param mixed $status The new status value.
* @param mixed $handler Optional handler context passed by kanban updates.
* @param string|null $legacyHook TEMPORARY (migration window): the emitting method name —
* pass __FUNCTION__ — used to rebuild the exact historical
* string name this site fired under for plugin listeners.
*/
public function __construct(
public readonly int $ticketId,
public readonly mixed $status,
public readonly mixed $handler = null,
private readonly ?string $legacyHook = null,
) {}
/**
* The exact historical string name of the emitting site. Remove with the migration window.
*
* @return array<int, string>
*/
public function legacyHooks(): array
{
if ($this->legacyHook === null) {
return [];
}
return ['leantime.domain.tickets.repositories.tickets.'.$this->legacyHook.'.ticketStatusUpdate'];
}
}

View File

@@ -0,0 +1,40 @@
<?php
namespace Leantime\Domain\Tickets\Events;
use Leantime\Core\Events\Concerns\InteractsWithEvents;
use Leantime\Core\Events\Contracts\LeantimeEvent;
/**
* Fired after a ticket (including subtasks) was updated.
*/
final class TicketUpdated implements LeantimeEvent
{
use InteractsWithEvents;
/**
* @param int|null $ticketId The updated ticket id; null for bulk updates (sorting,
* kanban status+sorting) where no single id applies.
* @param string|null $legacyHook TEMPORARY (migration window): the emitting method name —
* pass __FUNCTION__ — used to rebuild the exact historical
* string name this site fired under for plugin listeners.
*/
public function __construct(
public readonly ?int $ticketId = null,
private readonly ?string $legacyHook = null,
) {}
/**
* The exact historical string name of the emitting site. Remove with the migration window.
*
* @return array<int, string>
*/
public function legacyHooks(): array
{
if ($this->legacyHook === null) {
return [];
}
return ['leantime.domain.tickets.services.tickets.'.$this->legacyHook.'.ticket_updated'];
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace Leantime\Domain\Tickets\Events;
use Leantime\Core\Events\Concerns\InteractsWithFilters;
use Leantime\Core\Events\Contracts\LeantimeFilter;
/**
* Filters the current user's tasks before the My-ToDos widget renders them.
* Listeners receive the grouped tickets array and must return it (possibly modified).
*/
final class TodoWidgetTasksFilter implements LeantimeFilter
{
use InteractsWithFilters;
/**
* @param array $tickets The grouped widget tickets to filter.
* @param bool $hierarchical True when tickets are grouped hierarchically
* (milestone/parent nesting) instead of flat groups.
* @param string|null $legacyHook TEMPORARY (migration window): the emitting method name —
* pass __FUNCTION__ — used to rebuild the exact historical
* string name this site ran under for plugin listeners.
*/
public function __construct(
public array $tickets,
public readonly bool $hierarchical = false,
private readonly ?string $legacyHook = null,
) {}
/**
* The grouped tickets array threaded through the pipeline.
*/
public function payload(): mixed
{
return $this->tickets;
}
/**
* The exact historical string name of the emitting site. Remove with the migration window.
*
* @return array<int, string>
*/
public function legacyHooks(): array
{
if ($this->legacyHook === null) {
return [];
}
return ['leantime.domain.tickets.services.tickets.'.$this->legacyHook.'.myTodoWidgetTasks'];
}
}