Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UVDesk - unable to view/assign some tickets #740

Open
Niijimasama opened this issue Apr 25, 2024 · 7 comments
Open

UVDesk - unable to view/assign some tickets #740

Niijimasama opened this issue Apr 25, 2024 · 7 comments

Comments

@Niijimasama
Copy link

Niijimasama commented Apr 25, 2024

Bug report

I am unable to assign or view some tickets.
Switching from prod to dev mode shows the error "Impossible to access as attribute("createdAt") on a null variable. See image below:

uvdesk issue

Check on the database shows the tickets are generated (via RefereshMailbox Command) correctly. No errors on ticket generation.
Please help.

UVDesk Version v1.1.3; Core Version v1.1.4

@Niijimasama Niijimasama changed the title UVDesk - unable to view/assign tickets UVDesk - unable to view/assign some tickets Apr 25, 2024
@Niijimasama
Copy link
Author

Found my problem.

Tickets were being generated successfully but initial threads were not generated in the database.

Current solution has been to identify the tickets and manually create threads for them in the database table.

@Juan-DesignStudio
Copy link

I also have this issue, is there any permanent fix for this?

@Niijimasama
Copy link
Author

Not yet. If occurs because in the Mailbox Service does not have the exception to handle a situation where the ticket header is generated but the thread is not. I have created a program outside of UVDesk to handle this but it is not yet perfect. It can fetch the emails but not the images in the email, and no attachments yet. It also requires configuration and a cron job. I can share that if you want.

@Juan-DesignStudio
Copy link

Thanks, but I looked more into it and I think I was able to fix it you can test it out on your own if you want on the file /vendor/uvdesk/core-framework/Services/TicketService.php 287 function CreateThread

this line is the problem
$collaboratorEmails = array_merge(!empty($threadData['cccol']) ? $threadData['cccol'] : [], !empty($threadData['cc']) ? $threadData['cc'] : []);

I did it like this because of testing but if you replace that with this
$collaboratorEmails = [];

    //check if $threadData['cc'] is not empty then merge it with $collaboratorEmails
    if (!empty($threadData['cc'])) {
        //check if $threadData['cc'] is an array if not make it an array 
        if (!is_array($threadData['cc'])) {
            $threadData['cc'] = [$threadData['cc']];
        }

        $collaboratorEmails = array_merge($collaboratorEmails, $threadData['cc']);
    }

    //check if $threadData['cccol'] is not empty 
    if (!empty($threadData['cccol'])) {
        //check if $threadData['cccol'] is an array if not make it an array 
        if (!is_array($threadData['cccol'])) {
            $threadData['cccol'] = [$threadData['cccol']];
        }
        $collaboratorEmails = array_merge($collaboratorEmails, $threadData['cccol']);
    }

It should work

@Niijimasama
Copy link
Author

This is great, and thank you. I will definitely try it. My initial approach was to try and modify the mailbox service i.e. /vendor/uvdesk/mailbox-component/Services/MailboxService.php 453

I thought of capturing the exception at this point but all I could come up with was a message to show that the "bug" was occurring here.
Ichanged it from:

if (!empty($thread)) {
                // Thread with the same message id exists skip process.
                return [
                    'message' => "Thread with the same message id exists I.",
                    'content' => [
                        'from' => !empty($mailData['from']) ? $mailData['from'] : null,
                        'thread' => $thread->getId(),
                        'ticket' => $ticket->getId(),
                    ],
                ];
            }

to

if (!empty($thread)) {
                // Thread with the same message id exists skip process.
                return [
                    'message' => "Thread with the same message id exists I.",
                    'content' => [
                        'from' => !empty($mailData['from']) ? $mailData['from'] : null,
                        'thread' => $thread->getId(),
                        'ticket' => $ticket->getId(),
                    ],
                ];
            } else {
                // if ticket is not empty but thread is empty 
                $mailData['threadType'] = 'create';
                $mailData['referenceIds'] = $mailData['messageId'];
                $thread->getCreatedBy() == 'customer';
                
                return [
                    'message' => "I fall here.",
                    'content' => [
                        'from' => !empty($mailData['from']) ? $mailData['from'] : null,
                        'thread' => !empty($thread) ? $thread->getId() : null,
                        'ticket' => !empty($ticket) ? $ticket->getId() : null,
                    ],
                ];
                
            }

Will test and give you feedback in 2 days.

@Niijimasama
Copy link
Author

5 day feedback: Issues has disappeared so far. No childless tickets. Will give further feedback on/by 22nd June 2024 after a larger test dataset.

@Niijimasama
Copy link
Author

25th June 2024, issue has completely disappeared so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants