Skip to content

Commit

Permalink
fixup! feat: fiter messages by mention
Browse files Browse the repository at this point in the history
Signed-off-by: Hamza Mahjoubi <[email protected]>
  • Loading branch information
hamza221 committed Oct 10, 2024
1 parent 52dcf48 commit c4cd27e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/Db/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ static function (Tag $tag) {
'imipMessage' => $this->isImipMessage(),
'previewText' => $this->getPreviewText(),
'encrypted' => ($this->isEncrypted() === true),
'mentionsMe'=> $this->getMentionsMe(),
'mentionsMe' => $this->getMentionsMe(),
];
}
}
2 changes: 1 addition & 1 deletion lib/Db/MessageMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ public function findIdsByQuery(Mailbox $mailbox, SearchQuery $query, string $sor
);
}

if($query->getMentionsMe()){
if($query->getMentionsMe()) {
$select->andWhere(
$qb->expr()->eq('m.mentions_me', $qb->createNamedParameter($query->getMentionsMe(), IQueryBuilder::PARAM_BOOL))
);
Expand Down
8 changes: 4 additions & 4 deletions lib/IMAP/MessageMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class MessageMapper {

public function __construct(LoggerInterface $logger,
SmimeService $smimeService,
ImapMessageFetcherFactory $imapMessageFactory,) {
ImapMessageFetcherFactory $imapMessageFactory, ) {
$this->logger = $logger;
$this->smimeService = $smimeService;
$this->imapMessageFactory = $imapMessageFactory;
Expand Down Expand Up @@ -871,7 +871,7 @@ public function getBodyStructureData(Horde_Imap_Client_Socket $client,
$structures = $client->fetch($mailbox, $structureQuery, [
'ids' => new Horde_Imap_Client_Ids($uids),
]);
return array_map(function (Horde_Imap_Client_Data_Fetch $fetchData) use ($mailbox, $client,$emailAddress ) {
return array_map(function (Horde_Imap_Client_Data_Fetch $fetchData) use ($mailbox, $client, $emailAddress) {
$hasAttachments = false;
$text = '';
$isImipMessage = false;
Expand Down Expand Up @@ -939,7 +939,7 @@ public function getBodyStructureData(Horde_Imap_Client_Socket $client,
$structure->setContents($htmlBody);
$htmlBody = $structure->getContents();
}
$mentionsUser = $this->checkLinks($htmlBody,$emailAddress);
$mentionsUser = $this->checkLinks($htmlBody, $emailAddress);
$html = new Html2Text($htmlBody, ['do_links' => 'none','alt_image' => 'hide']);
return new MessageStructureData(
$hasAttachments,
Expand Down Expand Up @@ -976,7 +976,7 @@ private function checkLinks(string $body, string $mailAddress) : bool {
$anchors = $dom->getElementsByTagName('a');
foreach ($anchors as $anchor) {
$href = $anchor->getAttribute('href');
if($href === 'mailto:'.$mailAddress){
if($href === 'mailto:'.$mailAddress) {
return true;
}
}
Expand Down
4 changes: 3 additions & 1 deletion lib/Service/Search/FilterStringParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ private function parseFilterToken(SearchQuery $query, string $token): bool {
$query->setMatch($param);
return true;
case 'mentions':
$query->setMentionsMe(true);
if($param === 'true') {
$query->setMentionsMe(true);
}
return true;
case 'flags':
$flagArray = explode(',', $param);
Expand Down
8 changes: 4 additions & 4 deletions src/components/SearchMessages.vue
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,7 @@
</NcCheckboxRadioSwitch>
</div>
<div class="modal-inner-inline">
<NcCheckboxRadioSwitch :checked.sync="searchFlags"
value="mentions"
name="flags[]"
type="checkbox">
<NcCheckboxRadioSwitch :checked.sync="mentionsMe">
{{ t('mail', 'Mentions me') }}
</NcCheckboxRadioSwitch>
</div>
Expand Down Expand Up @@ -354,6 +351,7 @@ export default {
searchInSubject: null,
searchInMessageBody: null,
searchFlags: [],
mentionsMe: false,
hasAttachmentActive: false,
hasLast7daysActive: false,
hasFromMeActive: false,
Expand Down Expand Up @@ -414,6 +412,7 @@ export default {
body: this.searchInMessageBody !== null && this.searchInMessageBody.length > 1 ? this.searchInMessageBody : '',
tags: this.selectedTags.length > 0 ? this.selectedTags.map(item => item.id) : '',
flags: this.searchFlags.length > 0 ? this.searchFlags.map(item => item) : '',
mentions: this.mentionsMe,
start: this.prepareStart(),
end: this.prepareEnd(),
}
Expand Down Expand Up @@ -545,6 +544,7 @@ export default {
this.searchFlags = []
this.startDate = null
this.endDate = null
this.mentionsMe = false
// Need if there is only tag filter or recipients filter
if (prevQuery === '') {
this.sendQueryEvent()
Expand Down

0 comments on commit c4cd27e

Please sign in to comment.