Skip to content

Commit 0aa4f3d

Browse files
authored
Merge pull request #1148 from ittner/search-rule-for-item-author
Add seach rule to find items from a given author
2 parents 380add5 + f47da8f commit 0aa4f3d

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

doc/html/searching_en.html

+12
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ <h4>Permanent Searches with Search Folders</h4>
9393
</td></tr>
9494
<!-- ----------------------------------------- -->
9595
<tr><td style="background:#bfb">
96+
<b>Item author does contain</b>
97+
</td><td>
98+
<b>Adds</b> each item whose item author (or creator, acording to the feed) matches the given case insensitive string to the search folder.
99+
</td></tr>
100+
<!-- ----------------------------------------- -->
101+
<tr><td style="background:#fbb">
102+
<b>Item title does not contain</b>
103+
</td><td>
104+
<b>Removes</b> each item whose item author (or creator, acording to the feed) matches the given case insensitive string from the search folder.
105+
</td></tr>
106+
<!-- ----------------------------------------- -->
107+
<tr><td style="background:#bfb">
96108
<b>Item body does contain</b>
97109
</td><td>
98110
<b>Adds</b> each item whose item content matches the given case insensitive string to the search folder.

src/rule.c

+26
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#define ITEM_MATCH_RULE_ID "exact"
3131
#define ITEM_TITLE_MATCH_RULE_ID "exact_title"
3232
#define ITEM_DESC_MATCH_RULE_ID "exact_desc"
33+
#define ITEM_AUTHOR_MATCH_RULE_ID "exact_author"
3334
#define FEED_TITLE_MATCH_RULE_ID "feed_title"
3435
#define FEED_SOURCE_MATCH_RULE_ID "feed_source"
3536
#define PARENT_FOLDER_MATCH_RULE_ID "parent_folder"
@@ -184,6 +185,30 @@ rule_check_item_category (rulePtr rule, itemPtr item)
184185
return FALSE;
185186
}
186187

188+
static gboolean
189+
rule_check_item_author (rulePtr rule, itemPtr item)
190+
{
191+
GSList *iter;
192+
193+
iter = metadata_list_get_values (item->metadata, "author");
194+
while (iter) {
195+
if (rule_strcasecmp ((gchar *)iter->data, rule->valueCaseFolded)) {
196+
return TRUE;
197+
}
198+
iter = g_slist_next (iter);
199+
}
200+
201+
iter = metadata_list_get_values (item->metadata, "creator");
202+
while (iter) {
203+
if (rule_strcasecmp ((gchar *)iter->data, rule->valueCaseFolded)) {
204+
return TRUE;
205+
}
206+
iter = g_slist_next (iter);
207+
}
208+
return FALSE;
209+
}
210+
211+
187212
static gboolean
188213
rule_check_feed_title (rulePtr rule, itemPtr item)
189214
{
@@ -250,6 +275,7 @@ rule_init (void)
250275
rule_info_add (rule_check_item_all, ITEM_MATCH_RULE_ID, _("Item"), _("does contain"), _("does not contain"), TRUE);
251276
rule_info_add (rule_check_item_title, ITEM_TITLE_MATCH_RULE_ID, _("Item title"), _("does contain"), _("does not contain"), TRUE);
252277
rule_info_add (rule_check_item_description, ITEM_DESC_MATCH_RULE_ID, _("Item body"), _("does contain"), _("does not contain"), TRUE);
278+
rule_info_add (rule_check_item_author, ITEM_AUTHOR_MATCH_RULE_ID, _("Item author"), _("does contain"), _("does not contain"), TRUE);
253279
rule_info_add (rule_check_item_is_unread, "unread", _("Read status"), _("is unread"), _("is read"), FALSE);
254280
rule_info_add (rule_check_item_is_flagged, "flagged", _("Flag status"), _("is flagged"), _("is unflagged"), FALSE);
255281
rule_info_add (rule_check_item_has_enc, "enclosure", _("Enclosure"), _("included"), _("not included"), FALSE);

0 commit comments

Comments
 (0)