Skip to content

Commit

Permalink
fix: include @ and # on filter post (#815)
Browse files Browse the repository at this point in the history
fix: include @ and # on filter search post query
  • Loading branch information
abdulhakim2902 authored Mar 20, 2023
1 parent 33e01ba commit 8a1c21c
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions src/services/filter-builder.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ export class FilterBuilderService {

if (q.startsWith('#')) {
const hashtag = q.replace('#', '').trim().toLowerCase();
const hashtagRegexp = new RegExp(`#${hashtag}\\b`, 'i');

filterPost.push(
{
Expand Down Expand Up @@ -862,9 +863,46 @@ export class FilterBuilderService {
{createdBy: this.currentUser[securityId]},
],
},
{
and: [
{rawText: {regexp: hashtagRegexp}},
{visibility: VisibilityType.PUBLIC},
{createdBy: {nin: blockedFriendIds}},
],
},
{
and: [
{rawText: {regexp: hashtagRegexp}},
{visibility: VisibilityType.FRIEND},
{createdBy: {inq: approvedFriendIds}},
],
},
{
and: [
{rawText: {regexp: hashtagRegexp}},
{visibility: VisibilityType.SELECTED},
{selectedUserIds: {inq: [this.currentUser[securityId]]}} as Where,
{createdBy: {nin: blockedFriendIds}},
],
},
{
and: [
{rawText: {regexp: hashtagRegexp}},
{visibility: VisibilityType.TIMELINE},
{selectedUserIds: {inq: [this.currentUser[securityId]]}} as Where,
{createdBy: {nin: blockedFriendIds}},
],
},
{
and: [
{rawText: {regexp: hashtagRegexp}},
{createdBy: this.currentUser[securityId]},
],
},
);
} else if (q.startsWith('@')) {
const mention = q.replace('@', '').trim();
const mentionRegexp = new RegExp(`@${mention}\\b`, 'i');

filterPost.push(
{
Expand Down Expand Up @@ -923,6 +961,42 @@ export class FilterBuilderService {
{createdBy: this.currentUser[securityId]},
],
},
{
and: [
{rawText: {regexp: mentionRegexp}},
{visibility: VisibilityType.PUBLIC},
{createdBy: {nin: blockedFriendIds}},
],
},
{
and: [
{rawText: {regexp: mentionRegexp}},
{visibility: VisibilityType.FRIEND},
{createdBy: {inq: approvedFriendIds}},
],
},
{
and: [
{rawText: {regexp: mentionRegexp}},
{visibility: VisibilityType.SELECTED},
{selectedUserIds: {inq: [this.currentUser[securityId]]}} as Where,
{createdBy: {nin: blockedFriendIds}},
],
},
{
and: [
{rawText: {regexp: mentionRegexp}},
{visibility: VisibilityType.TIMELINE},
{selectedUserIds: {inq: [this.currentUser[securityId]]}} as Where,
{createdBy: {nin: blockedFriendIds}},
],
},
{
and: [
{rawText: {regexp: mentionRegexp}},
{createdBy: this.currentUser[securityId]},
],
},
);
} else {
const regexTopic = new RegExp(`\\b${q}\\b`, 'i');
Expand Down

0 comments on commit 8a1c21c

Please sign in to comment.