Skip to content

Commit

Permalink
persist to-field
Browse files Browse the repository at this point in the history
  • Loading branch information
apparition47 committed Jun 9, 2024
1 parent 36baf7c commit 87dc497
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
7 changes: 2 additions & 5 deletions Resources/Reports.xcdatamodeld/Reports.xcdatamodel/contents
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="18154" systemVersion="20E241" minimumToolsVersion="Automatic" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier="">
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="22522" systemVersion="23F79" minimumToolsVersion="Automatic" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier="">
<entity name="Email" representedClassName="Email" syncable="YES" codeGenerationType="class">
<attribute name="deeplink" optional="YES" attributeType="String"/>
<attribute name="read_timestamp" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="subject" optional="YES" attributeType="String"/>
<attribute name="to" optional="YES" attributeType="String"/>
<relationship name="tracker" optional="YES" maxCount="1" deletionRule="Cascade" destinationEntity="Tracker" inverseName="reports" inverseEntity="Tracker"/>
</entity>
<entity name="Tracker" representedClassName="Tracker" syncable="YES" codeGenerationType="class">
<attribute name="name" optional="YES" attributeType="String"/>
<relationship name="reports" toMany="YES" minCount="1" deletionRule="No Action" destinationEntity="Email" inverseName="tracker" inverseEntity="Email"/>
</entity>
<elements>
<element name="Email" positionX="-28.73736572265625" positionY="-280.8207397460938" width="128" height="103"/>
<element name="Tracker" positionX="-18" positionY="54" width="128" height="59"/>
</elements>
</model>
3 changes: 2 additions & 1 deletion Source/MTBBlockedMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ typedef NS_ENUM(NSUInteger, BLOCKING_RESULT_CERTAINTY) {
@interface MTBBlockedMessage : NSObject
@property(readonly, nonatomic) NSString *subjectField;
@property(readonly, nonatomic) NSString *fromField;
@property(readonly, nonatomic) NSString *toField;
@property(readonly, nonatomic) NSString *deeplinkField;
@property(readonly, nonatomic) NSString *originalHtml;
@property (assign) BOOL isBlockingEnabled;
// Total number of generic and named trackers
@property (nonatomic, assign, readonly) NSUInteger knownTrackerCount;
- (instancetype)init NS_UNAVAILABLE;
- (id)initWithHtml:(NSString*)html;
- (id)initWithHtml:(NSString*)html from:(NSString*)from subject:(NSString*)subject deeplink:(NSString*)deeplink;
- (id)initWithHtml:(NSString*)html to:(NSString*)to from:(NSString*)from subject:(NSString*)subject deeplink:(NSString*)deeplink;
- (NSString *)detectedTracker;
// Returns display names of trackers detected in message
- (NSSet<NSString*> *)detectedTrackers;
Expand Down
3 changes: 2 additions & 1 deletion Source/MTBBlockedMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ - (id)initWithHtml:(NSString*)html {
return self;
}

- (id)initWithHtml:(NSString*)html from:(NSString*)from subject:(NSString*)subject deeplink:(NSString*)deeplink {
- (id)initWithHtml:(NSString*)html to:(NSString*)to from:(NSString*)from subject:(NSString*)subject deeplink:(NSString*)deeplink {
self = [self init];
if (!self) {
return nil;
}
_originalHtml = html;
_sanitizedHtml = [self sanitizedHtmlFromHtml: html];
_deeplinkField = deeplink;
_toField = to;
_fromField = from;
_subjectField = subject;
return self;
Expand Down
2 changes: 2 additions & 0 deletions Source/MTBReportingManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ -(void)markEmailRead:(MTBBlockedMessage*)blkMsg {
email = [NSEntityDescription insertNewObjectForEntityForName:@"Email" inManagedObjectContext:context];
[email setSubject:blkMsg.subjectField];
[email setDeeplink:blkMsg.deeplinkField];
[email setTo:blkMsg.toField];
[email setRead_timestamp:[NSDate date]];
} else if (fetchResults.count > 0) {
// id'd tracker exists and is same as previous record
Expand All @@ -55,6 +56,7 @@ -(void)markEmailRead:(MTBBlockedMessage*)blkMsg {
email = [NSEntityDescription insertNewObjectForEntityForName:@"Email" inManagedObjectContext:context];
[email setSubject:blkMsg.subjectField];
[email setDeeplink:blkMsg.deeplinkField];
[email setTo:blkMsg.toField];
[email setRead_timestamp:[NSDate date]];
}

Expand Down
2 changes: 1 addition & 1 deletion Source/WebDocumentGenerator+MailTrackerBlocker.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ @implementation WebDocumentGenerator_MailTrackerBlocker

- (void)MTBSetWebDocument:(MUIWebDocument *)webDocument {
ConversationMember *member = [mailself conversationMember];
MTBBlockedMessage *blkMsg = [[MTBBlockedMessage alloc] initWithHtml:webDocument.html from:member.sender subject:member.subject deeplink:member.originalMessage.URLString];
MTBBlockedMessage *blkMsg = [[MTBBlockedMessage alloc] initWithHtml:webDocument.html to:member.mailboxName from:member.sender subject:member.subject deeplink:member.originalMessage.URLString];
[[mailself conversationMember] setIvar: @"MTBBlockedMessage" value: blkMsg];
webDocument.html = [blkMsg sanitizedHtml];
[self MTBSetWebDocument:webDocument];
Expand Down

1 comment on commit 87dc497

@apparition47
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In anticipation of a multi-account/inbox filter on the Tracker Report (#140)

Please sign in to comment.