@@ -61,7 +61,7 @@ import dfeed.web.web.view.search : discussionSearch;
6161import dfeed.web.web.view.settings;
6262import dfeed.web.web.view.subscription : discussionSubscriptionPosts, discussionSubscriptionUnsubscribe;
6363import dfeed.web.web.view.thread : getPostAtThreadIndex, discussionThread, discussionFirstUnread;
64- import dfeed.web.web.view.userprofile : discussionUserProfile;
64+ import dfeed.web.web.view.userprofile : discussionUserProfile, lookupAuthorByHash ;
6565import dfeed.web.web.view.widgets;
6666
6767import ae.net.http.common : HttpRequest, HttpResponse, HttpStatusCode;
@@ -74,7 +74,7 @@ import ae.utils.digest;
7474import ae.utils.exception;
7575import ae.utils.json : toJson;
7676import ae.utils.meta : I;
77- import ae.utils.regex : re;
77+ import ae.utils.regex : re, escapeRE ;
7878import ae.utils.text.html : encodeHtmlEntities;
7979
8080HttpRequest currentRequest;
@@ -548,6 +548,32 @@ HttpResponse handleRequest(HttpRequest request, HttpServerConnection conn)
548548 breadcrumbs ~= ` <a href="/user/` ~ encodeHtmlEntities(profileHash) ~ ` ">` ~ encodeHtmlEntities(author) ~ ` </a>` ;
549549 break ;
550550 }
551+ case " subscribe-user" :
552+ {
553+ enforce(path.length > 1 , _! " No user specified" );
554+ enforce(user.isLoggedIn(), _! " Please log in to do that" );
555+ string profileHash = pathX;
556+ auto authorInfo = lookupAuthorByHash(profileHash);
557+ enforce(authorInfo[0 ] ! is null , _! " User not found" );
558+ string authorName = authorInfo[0 ];
559+ string authorEmail = authorInfo[1 ];
560+
561+ // Create a content subscription with author name and email filters prefilled
562+ // Use regex mode with escaped strings for exact matching
563+ auto subscription = createSubscription(user.getName(), " content" , [
564+ " trigger-content-author-name-enabled" : " on" ,
565+ " trigger-content-author-name-match-type" : " regex" ,
566+ " trigger-content-author-name-case-sensitive" : " on" ,
567+ " trigger-content-author-name-str" : " ^" ~ authorName.escapeRE ~ " $" ,
568+ " trigger-content-author-email-enabled" : " on" ,
569+ " trigger-content-author-email-match-type" : " regex" ,
570+ " trigger-content-author-email-case-sensitive" : " on" ,
571+ " trigger-content-author-email-str" : " ^" ~ authorEmail.escapeRE ~ " $" ,
572+ ]);
573+ title = _! " Subscribe to user" ;
574+ discussionSubscriptionEdit(subscription);
575+ break ;
576+ }
551577 case " delete" :
552578 case " dodelete" :
553579 return response.redirect(" /moderate/" ~ path[1 .. $].join(" /" ));
0 commit comments