Comments (1)
For someone who has the same problem with Amazon Messages, this fixes our requirement:
/**
* Merge new threads from Amazon customers
*
*/
\Eventy::addFilter('conversation.created_by_customer', function ($conversation, $thread, $customer) {
if (!empty($thread) && $thread->from && strpos($thread->from, '@marketplace.amazon.de') !== false) {
$mailbox = $conversation->mailbox;
$prev_conversations = $mailbox->conversations()
->where('customer_id', $customer->id)
->where('id', '<>', $conversation->id)
->where('status', '!=', Conversation::STATUS_SPAM)
->where('state', Conversation::STATE_PUBLISHED)
//->limit(100)
->orderBy('created_at', 'desc')
->get();
foreach ($prev_conversations as $prev_conversation) {
// Move all threads from old to new conversation.
foreach ($prev_conversation->threads as $thread) {
$thread->conversation_id = $conversation->id;
$thread->setMeta(Thread::META_PREV_CONVERSATION, $prev_conversation->id);
$thread->save();
}
if ($prev_conversation->has_attachments && !$conversation->has_attachments) {
$conversation->has_attachments = true;
$conversation->save();
}
// Move star mark.
$mailbox_star_folders = Folder::where('mailbox_id', $prev_conversation->mailbox_id)
->where('type', Folder::TYPE_STARRED)
->get();
$conv_star_folder_ids = ConversationFolder::select('folder_id')
->whereIn('folder_id', $mailbox_star_folders->pluck('id'))
->where('conversation_id', $prev_conversation->id)
->pluck('folder_id');
foreach ($conv_star_folder_ids as $conv_star_folder_id) {
$folder = $mailbox_star_folders->find($conv_star_folder_id);
if ($folder->user) {
$conversation->star($folder->user);
$prev_conversation->unstar($folder->user);
}
}
// Delete old conversation.
$prev_conversation->delete();
// Update counters.
$mailbox->updateFoldersCounters();
if ($conversation->mailbox_id != $prev_conversation->mailbox_id) {
$prev_conversation->mailbox->updateFoldersCounters();
}
}
}
return $conversation;
}, 20, 3);
from freescout.
Related Issues (20)
- Data isolation between operators authorized for different mailboxes. HOT 1
- Settings not saving all of a sudden? HOT 4
- Satisfaction Ratings in chats HOT 2
- Using URL instead of cron doesn't fetch emails HOT 2
- Cronjob via link not working HOT 6
- Freescout IMAP connection error - SMTP is connecting HOT 1
- Help me identify why my server is reaching timeout with 504 error HOT 1
- MySQL 8 / PHP 8.3 Supported? HOT 1
- Can't send regular emails, but test emails do get sent (migadu) - [NEED HELP PLEASE] HOT 2
- "Force OAuth Login" logs all users in as user 1 HOT 1
- [Bug]: Exclude non-URL character from a link while composing a ticket HOT 1
- [Enhancement]: Link an email address automatically while composing a ticket HOT 1
- Workflow Module: Post-Move Workflow results into "too many redirects" HOT 4
- Users other than admin cannot access fresh install - page has expired due to inactivity HOT 7
- Mail not Sent after cloning HOT 5
- Too many redirect - Knowledge Base HOT 1
- Sort conversations in Custom Folder in ascending order by the last_reply_at column by default HOT 6
- How do we remove the Freescout signature at the end of every ticket ? HOT 1
- A module for accessing organization tickets. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from freescout.