added posting private posts

This commit is contained in:
Jeena Paradies 2012-12-22 19:37:03 +01:00
parent eb540fae1d
commit 2ca5d1ea68
12 changed files with 144 additions and 92 deletions

View file

@ -61,7 +61,7 @@
- (void)initWebViews; - (void)initWebViews;
- (void)initHotKeys; - (void)initHotKeys;
- (void)alertTitle:(NSString *)title withMessage:(NSString *)message; - (void)alertTitle:(NSString *)title withMessage:(NSString *)message;
- (void)openNewMessageWindowInReplyTo:(NSString *)userName statusId:(NSString *)statusId withString:(NSString *)string; - (void)openNewMessageWindowInReplyTo:(NSString *)userName statusId:(NSString *)statusId withString:(NSString *)string isPrivate:(BOOL)isPrivate;
- (NSString *)pluginURL; - (NSString *)pluginURL;
- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent; - (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
- (void)unreadMentions:(int)count; - (void)unreadMentions:(int)count;

View file

@ -296,11 +296,12 @@
[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil]; [[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil];
} }
- (void)openNewMessageWindowInReplyTo:(NSString *)userName statusId:(NSString *)statusId withString:(NSString *)string - (void)openNewMessageWindowInReplyTo:(NSString *)userName statusId:(NSString *)statusId withString:(NSString *)string isPrivate:(BOOL)isPrivate
{ {
[NSApp activateIgnoringOtherApps:YES]; [NSApp activateIgnoringOtherApps:YES];
NewMessageWindow *newTweet = (NewMessageWindow *)[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil]; NewMessageWindow *newMessage = (NewMessageWindow *)[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil];
[newTweet inReplyTo:userName statusId:statusId withString:string]; [newMessage inReplyTo:userName statusId:statusId withString:string];
[newMessage setIsPrivate:isPrivate];
} }
- (void)openNewMessageWindowWithString:(NSString *)aString - (void)openNewMessageWindowWithString:(NSString *)aString
@ -347,12 +348,18 @@
imageFilePath = [NSString stringWithFormat:@"\"data:%@;base64,%@\"", mimeType, base64]; imageFilePath = [NSString stringWithFormat:@"\"data:%@;base64,%@\"", mimeType, base64];
} }
NSString *func = [NSString stringWithFormat:@"tentia_instance.sendNewMessage(\"%@\", \"%@\", \"%@\", %@, %@)", NSString *isPrivate = @"false";
if (post.isPrivate) {
isPrivate = @"true";
}
NSString *func = [NSString stringWithFormat:@"tentia_instance.sendNewMessage(\"%@\", \"%@\", \"%@\", %@, %@, %@)",
text, text,
post.inReplyTostatusId, post.inReplyTostatusId,
post.inReplyToEntity, post.inReplyToEntity,
locationObject, locationObject,
imageFilePath]; imageFilePath,
isPrivate];
[timelineView stringByEvaluatingJavaScriptFromString:func]; [timelineView stringByEvaluatingJavaScriptFromString:func];
} }

View file

@ -131,14 +131,14 @@
<string key="NSFrame">{{2, 0}, {18, 19}}</string> <string key="NSFrame">{{2, 0}, {18, 19}}</string>
<reference key="NSSuperview" ref="568628114"/> <reference key="NSSuperview" ref="568628114"/>
<reference key="NSWindow"/> <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="184011745"/> <reference key="NSNextKeyView" ref="306901015"/>
<string key="NSReuseIdentifierKey">_NS:9</string> <string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="482669194"> <object class="NSButtonCell" key="NSCell" id="482669194">
<int key="NSCellFlags">67108864</int> <int key="NSCellFlags">67108864</int>
<int key="NSCellFlags2">134217728</int> <int key="NSCellFlags2">134217728</int>
<string key="NSContents"/> <string key="NSContents"/>
<object class="NSFont" key="NSSupport"> <object class="NSFont" key="NSSupport" id="29">
<string key="NSName">LucidaGrande-Bold</string> <string key="NSName">LucidaGrande-Bold</string>
<double key="NSSize">12</double> <double key="NSSize">12</double>
<int key="NSfFlags">16</int> <int key="NSfFlags">16</int>
@ -187,6 +187,35 @@
</object> </object>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool> <bool key="NSAllowsLogicalLayoutDirection">NO</bool>
</object> </object>
<object class="NSButton" id="306901015">
<reference key="NSNextResponder" ref="568628114"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 1}, {19, 19}}</string>
<reference key="NSSuperview" ref="568628114"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="184011745"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="448152979">
<int key="NSCellFlags">67108864</int>
<int key="NSCellFlags2">134217728</int>
<string key="NSContents"/>
<reference key="NSSupport" ref="29"/>
<string key="NSCellIdentifier">_NS:9</string>
<reference key="NSControlView" ref="306901015"/>
<int key="NSButtonFlags">113524736</int>
<int key="NSButtonFlags2">268435629</int>
<object class="NSCustomResource" key="NSNormalImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSLockUnlockedTemplate</string>
</object>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent">p</string>
<int key="NSPeriodicDelay">200</int>
<int key="NSPeriodicInterval">25</int>
</object>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
</object>
</object> </object>
<string key="NSFrameSize">{299, 113}</string> <string key="NSFrameSize">{299, 113}</string>
<reference key="NSSuperview"/> <reference key="NSSuperview"/>
@ -394,6 +423,22 @@ A</bytes>
</object> </object>
<int key="connectionID">100073</int> <int key="connectionID">100073</int>
</object> </object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">togglePrivate:</string>
<reference key="source" ref="512844837"/>
<reference key="destination" ref="306901015"/>
</object>
<int key="connectionID">100076</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">togglePrivateButton</string>
<reference key="source" ref="512844837"/>
<reference key="destination" ref="306901015"/>
</object>
<int key="connectionID">100080</int>
</object>
<object class="IBConnectionRecord"> <object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection"> <object class="IBOutletConnection" key="connection">
<string key="label">delegate</string> <string key="label">delegate</string>
@ -453,6 +498,7 @@ A</bytes>
<reference ref="482035741"/> <reference ref="482035741"/>
<reference ref="647941004"/> <reference ref="647941004"/>
<reference ref="184011745"/> <reference ref="184011745"/>
<reference ref="306901015"/>
</object> </object>
<reference key="parent" ref="275939982"/> <reference key="parent" ref="275939982"/>
</object> </object>
@ -552,6 +598,20 @@ A</bytes>
<reference key="object" ref="486389227"/> <reference key="object" ref="486389227"/>
<reference key="parent" ref="723763594"/> <reference key="parent" ref="723763594"/>
</object> </object>
<object class="IBObjectRecord">
<int key="objectID">100074</int>
<reference key="object" ref="306901015"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="448152979"/>
</object>
<reference key="parent" ref="568628114"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">100075</int>
<reference key="object" ref="448152979"/>
<reference key="parent" ref="306901015"/>
</object>
</object> </object>
</object> </object>
<object class="NSMutableDictionary" key="flattenedProperties"> <object class="NSMutableDictionary" key="flattenedProperties">
@ -574,6 +634,8 @@ A</bytes>
<string>100065.IBPluginDependency</string> <string>100065.IBPluginDependency</string>
<string>100066.IBPluginDependency</string> <string>100066.IBPluginDependency</string>
<string>100071.IBPluginDependency</string> <string>100071.IBPluginDependency</string>
<string>100074.IBPluginDependency</string>
<string>100075.IBPluginDependency</string>
<string>5.IBPluginDependency</string> <string>5.IBPluginDependency</string>
<string>5.IBWindowTemplateEditedContentRect</string> <string>5.IBWindowTemplateEditedContentRect</string>
<string>6.IBPluginDependency</string> <string>6.IBPluginDependency</string>
@ -597,6 +659,8 @@ A</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{127, 736}, {299, 113}}</string> <string>{{127, 736}, {299, 113}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object> </object>
@ -613,78 +677,11 @@ A</bytes>
<reference key="dict.values" ref="0"/> <reference key="dict.values" ref="0"/>
</object> </object>
<nil key="sourceID"/> <nil key="sourceID"/>
<int key="maxID">100073</int> <int key="maxID">100080</int>
</object> </object>
<object class="IBClassDescriber" key="IBDocument.Classes"> <object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions"> <object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">NSDocument</string>
<object class="NSMutableDictionary" key="actions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>printDocument:</string>
<string>revertDocumentToSaved:</string>
<string>runPageLayout:</string>
<string>saveDocument:</string>
<string>saveDocumentAs:</string>
<string>saveDocumentTo:</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>printDocument:</string>
<string>revertDocumentToSaved:</string>
<string>runPageLayout:</string>
<string>saveDocument:</string>
<string>saveDocumentAs:</string>
<string>saveDocumentTo:</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBActionInfo">
<string key="name">printDocument:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">revertDocumentToSaved:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">runPageLayout:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">saveDocument:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">saveDocumentAs:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">saveDocumentTo:</string>
<string key="candidateClassName">id</string>
</object>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/NSDocument.h</string>
</object>
</object>
<object class="IBPartialClassDescription"> <object class="IBPartialClassDescription">
<string key="className">NewMessageWindow</string> <string key="className">NewMessageWindow</string>
<string key="superclassName">NSDocument</string> <string key="superclassName">NSDocument</string>
@ -697,6 +694,7 @@ A</bytes>
<string>openAddMenu:</string> <string>openAddMenu:</string>
<string>sendPost:</string> <string>sendPost:</string>
<string>sendPostButtonPressed:</string> <string>sendPostButtonPressed:</string>
<string>togglePrivate:</string>
</object> </object>
<object class="NSArray" key="dict.values"> <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
@ -705,6 +703,7 @@ A</bytes>
<string>id</string> <string>id</string>
<string>NSControl</string> <string>NSControl</string>
<string>id</string> <string>id</string>
<string>id</string>
</object> </object>
</object> </object>
<object class="NSMutableDictionary" key="actionInfosByName"> <object class="NSMutableDictionary" key="actionInfosByName">
@ -716,6 +715,7 @@ A</bytes>
<string>openAddMenu:</string> <string>openAddMenu:</string>
<string>sendPost:</string> <string>sendPost:</string>
<string>sendPostButtonPressed:</string> <string>sendPostButtonPressed:</string>
<string>togglePrivate:</string>
</object> </object>
<object class="NSArray" key="dict.values"> <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
@ -739,6 +739,10 @@ A</bytes>
<string key="name">sendPostButtonPressed:</string> <string key="name">sendPostButtonPressed:</string>
<string key="candidateClassName">id</string> <string key="candidateClassName">id</string>
</object> </object>
<object class="IBActionInfo">
<string key="name">togglePrivate:</string>
<string key="candidateClassName">id</string>
</object>
</object> </object>
</object> </object>
<object class="NSMutableDictionary" key="outlets"> <object class="NSMutableDictionary" key="outlets">
@ -749,6 +753,7 @@ A</bytes>
<string>addMenuButton</string> <string>addMenuButton</string>
<string>counter</string> <string>counter</string>
<string>textField</string> <string>textField</string>
<string>togglePrivateButton</string>
</object> </object>
<object class="NSArray" key="dict.values"> <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
@ -756,6 +761,7 @@ A</bytes>
<string>NSButton</string> <string>NSButton</string>
<string>NSTextField</string> <string>NSTextField</string>
<string>NSTextField</string> <string>NSTextField</string>
<string>NSButton</string>
</object> </object>
</object> </object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName"> <object class="NSMutableDictionary" key="toOneOutletInfosByName">
@ -766,6 +772,7 @@ A</bytes>
<string>addMenuButton</string> <string>addMenuButton</string>
<string>counter</string> <string>counter</string>
<string>textField</string> <string>textField</string>
<string>togglePrivateButton</string>
</object> </object>
<object class="NSArray" key="dict.values"> <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
@ -785,6 +792,10 @@ A</bytes>
<string key="name">textField</string> <string key="name">textField</string>
<string key="candidateClassName">NSTextField</string> <string key="candidateClassName">NSTextField</string>
</object> </object>
<object class="IBToOneOutletInfo">
<string key="name">togglePrivateButton</string>
<string key="candidateClassName">NSButton</string>
</object>
</object> </object>
</object> </object>
<object class="IBClassDescriptionSource" key="sourceIdentifier"> <object class="IBClassDescriptionSource" key="sourceIdentifier">
@ -807,12 +818,14 @@ A</bytes>
<object class="NSArray" key="dict.sortedKeys"> <object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<string>NSAddTemplate</string> <string>NSAddTemplate</string>
<string>NSLockUnlockedTemplate</string>
<string>NSMenuCheckmark</string> <string>NSMenuCheckmark</string>
<string>NSMenuMixedState</string> <string>NSMenuMixedState</string>
</object> </object>
<object class="NSArray" key="dict.values"> <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<string>{8, 8}</string> <string>{8, 8}</string>
<string>{9, 12}</string>
<string>{11, 11}</string> <string>{11, 11}</string>
<string>{10, 3}</string> <string>{10, 3}</string>
</object> </object>

View file

@ -23,6 +23,7 @@
CLLocationManager *locationManager; CLLocationManager *locationManager;
CLLocation *currentLocation; CLLocation *currentLocation;
NSString *imageFilePath; NSString *imageFilePath;
NSButton *togglePrivateButton;
} }
@property (nonatomic, retain) IBOutlet NSTextField *textField; @property (nonatomic, retain) IBOutlet NSTextField *textField;
@ -32,6 +33,7 @@
@property (retain, nonatomic) CLLocationManager *locationManager; @property (retain, nonatomic) CLLocationManager *locationManager;
@property (retain, nonatomic) CLLocation *currentLocation; @property (retain, nonatomic) CLLocation *currentLocation;
@property (retain, nonatomic) NSString *imageFilePath; @property (retain, nonatomic) NSString *imageFilePath;
@property (assign) IBOutlet NSButton *togglePrivateButton;
- (IBAction)sendPost:(NSControl *)control; - (IBAction)sendPost:(NSControl *)control;
- (void)inReplyTo:(NSString *)userName statusId:(NSString *)statusId withString:(NSString *)string; - (void)inReplyTo:(NSString *)userName statusId:(NSString *)statusId withString:(NSString *)string;
@ -39,5 +41,7 @@
- (IBAction)addCurrentLocation:(id)sender; - (IBAction)addCurrentLocation:(id)sender;
- (IBAction)addImage:(id)sender; - (IBAction)addImage:(id)sender;
- (IBAction)openAddMenu:(id)sender; - (IBAction)openAddMenu:(id)sender;
- (IBAction)togglePrivate:(id)sender;
- (void)setIsPrivate:(BOOL)isPrivate;
@end @end

View file

@ -23,6 +23,7 @@
@synthesize textField, counter; @synthesize textField, counter;
@synthesize locationManager, currentLocation; @synthesize locationManager, currentLocation;
@synthesize imageFilePath; @synthesize imageFilePath;
@synthesize togglePrivateButton;
- (void)dealloc - (void)dealloc
{ {
@ -159,6 +160,21 @@
[NSMenu popUpContextMenu:self.addMenu withEvent:event forView:self.addMenuButton]; [NSMenu popUpContextMenu:self.addMenu withEvent:event forView:self.addMenuButton];
} }
- (IBAction)togglePrivate:(id)sender
{
NSImage *image = [NSImage imageNamed:NSImageNameLockLockedTemplate];
if (self.togglePrivateButton.image == [NSImage imageNamed:NSImageNameLockLockedTemplate])
{
image = [NSImage imageNamed:NSImageNameLockUnlockedTemplate];
}
[self.togglePrivateButton setImage:image];
}
- (void)setIsPrivate:(BOOL)isPrivate {
NSImage *image = [NSImage imageNamed:(isPrivate ? NSImageNameLockLockedTemplate : NSImageNameLockUnlockedTemplate)];
[self.togglePrivateButton setImage:image];
}
-(void)controlTextDidChange:(NSNotification *)aNotification { -(void)controlTextDidChange:(NSNotification *)aNotification {
NSInteger c = MESSAGE_MAX_LENGTH - [[textField stringValue] length]; NSInteger c = MESSAGE_MAX_LENGTH - [[textField stringValue] length];
[counter setIntValue:c]; [counter setIntValue:c];
@ -207,6 +223,7 @@
post.inReplyToEntity = inReplyToEntity; post.inReplyToEntity = inReplyToEntity;
post.location = self.currentLocation; post.location = self.currentLocation;
post.imageFilePath = self.imageFilePath; post.imageFilePath = self.imageFilePath;
post.isPrivate = self.togglePrivateButton.image == [NSImage imageNamed:NSImageNameLockLockedTemplate];
[[NSNotificationCenter defaultCenter] postNotificationName:@"sendTweet" object:post]; [[NSNotificationCenter defaultCenter] postNotificationName:@"sendTweet" object:post];
[self close]; [self close];
} else { } else {

View file

@ -15,6 +15,7 @@
NSString *inReplyToEntity; NSString *inReplyToEntity;
CLLocation *location; CLLocation *location;
NSString *imageFilePath; NSString *imageFilePath;
BOOL isPrivate;
} }
@property (nonatomic, retain) NSString *text; @property (nonatomic, retain) NSString *text;
@ -22,5 +23,6 @@
@property (nonatomic, retain) NSString *inReplyToEntity; @property (nonatomic, retain) NSString *inReplyToEntity;
@property (nonatomic, retain) CLLocation *location; @property (nonatomic, retain) CLLocation *location;
@property (nonatomic, retain) NSString *imageFilePath; @property (nonatomic, retain) NSString *imageFilePath;
@property (nonatomic) BOOL isPrivate;
@end @end

View file

@ -11,7 +11,7 @@
@implementation PostModel @implementation PostModel
@synthesize text, inReplyTostatusId, inReplyToEntity, location, imageFilePath; @synthesize text, inReplyTostatusId, inReplyToEntity, location, imageFilePath, isPrivate;
- (void)dealloc - (void)dealloc
{ {

View file

@ -71,7 +71,7 @@ function(HostApp, Core, Paths, URI) {
if (e.startsWith("https://")) { if (e.startsWith("https://")) {
e = e.substr(8, e.length); e = e.substr(8, e.length);
} }
HostApp.openNewMessageWidow(null, null, "^" + e + " "); HostApp.openNewMessageWidow(null, null, "^" + e + " ", false);
} }
div.appendChild(this.profile_template.mention_button); div.appendChild(this.profile_template.mention_button);
this.profile_template.mention_button.innerHTML = "Mention"; this.profile_template.mention_button.innerHTML = "Mention";

View file

@ -128,10 +128,10 @@ function(Core, Paths, HostApp, URI) {
} }
} }
Timeline.prototype.sendNewMessage = function(content, in_reply_to_status_id, in_reply_to_entity, location, image_data_uri) { Timeline.prototype.sendNewMessage = function(content, in_reply_to_status_id, in_reply_to_entity, location, image_data_uri, is_private) {
var _this = this; var _this = this;
var callback = function(data) { _this.getNewData(); } var callback = function(data) { _this.getNewData(); }
Core.prototype.sendNewMessage.call(this, content, in_reply_to_status_id, in_reply_to_entity, location, image_data_uri, callback); Core.prototype.sendNewMessage.call(this, content, in_reply_to_status_id, in_reply_to_entity, location, image_data_uri, is_private, callback);
} }
Timeline.prototype.remove = function(id) { Timeline.prototype.remove = function(id) {

View file

@ -171,7 +171,7 @@ function(jQuery, Paths, URI, HostApp, Cache) {
mentions.push(mention); mentions.push(mention);
} }
_this.replyTo(status.entity, status.id, mentions); _this.replyTo(status.entity, status.id, mentions, (status && status.permissions && !status.permissions.public));
return false; return false;
} }
@ -399,11 +399,11 @@ function(jQuery, Paths, URI, HostApp, Cache) {
} }
} }
Core.prototype.sendNewMessage = function(content, in_reply_to_status_id, in_reply_to_entity, location, image_file_path, callback) { Core.prototype.sendNewMessage = function(content, in_reply_to_status_id, in_reply_to_entity, location, image_file_path, is_private, callback) {
if (image_file_path) { if (image_file_path) {
this.sendNewMessageWithImage(content, in_reply_to_status_id, in_reply_to_entity, location, image_file_path, callback); this.sendNewMessageWithImage(content, in_reply_to_status_id, in_reply_to_entity, location, image_file_path, is_private, callback);
} else { } else {
@ -415,7 +415,7 @@ function(jQuery, Paths, URI, HostApp, Cache) {
"type": "https://tent.io/types/post/status/v0.1.0", "type": "https://tent.io/types/post/status/v0.1.0",
"published_at": parseInt(new Date().getTime() / 1000, 10), "published_at": parseInt(new Date().getTime() / 1000, 10),
"permissions": { "permissions": {
"public": true "public": !is_private
}, },
"content": { "content": {
"text": content, "text": content,
@ -430,6 +430,15 @@ function(jQuery, Paths, URI, HostApp, Cache) {
if (mentions.length > 0) { if (mentions.length > 0) {
data["mentions"] = mentions; data["mentions"] = mentions;
if (is_private) {
var entities = {};
for (var i = 0; i < mentions.length; i++) {
var entity = mentions[i]["entity"]
entities[entity] = true;
};
data["permissions"]["entities"] = entities;
}
} }
Paths.getURL(url.toString(), http_method, callback, JSON.stringify(data)); Paths.getURL(url.toString(), http_method, callback, JSON.stringify(data));
@ -708,7 +717,7 @@ function(jQuery, Paths, URI, HostApp, Cache) {
return text.replace(hash, "$1$2<a href='https://skate.io/search?q=%23$3'>$3</a>"); return text.replace(hash, "$1$2<a href='https://skate.io/search?q=%23$3'>$3</a>");
} }
Core.prototype.replyTo = function(entity, status_id, mentions) { Core.prototype.replyTo = function(entity, status_id, mentions, is_private) {
var string = "^" + entity.replace("https://", "") + " "; var string = "^" + entity.replace("https://", "") + " ";
for (var i = 0; i < mentions.length; i++) { for (var i = 0; i < mentions.length; i++) {
@ -716,7 +725,7 @@ function(jQuery, Paths, URI, HostApp, Cache) {
if(string.indexOf(e) == -1) string += "^" + e + " "; if(string.indexOf(e) == -1) string += "^" + e + " ";
} }
HostApp.openNewMessageWidow(entity, status_id, string); HostApp.openNewMessageWidow(entity, status_id, string, is_private);
} }
return Core; return Core;

View file

@ -69,12 +69,12 @@ define(function() {
} }
} }
HostApp.openNewMessageWidow = function(entity, status_id, string) { HostApp.openNewMessageWidow = function(entity, status_id, string, is_private) {
if (OS_TYPE == "mac") { if (OS_TYPE == "mac") {
controller.openNewMessageWindowInReplyTo_statusId_withString_(entity, status_id, string); controller.openNewMessageWindowInReplyTo_statusId_withString_isPrivate_(entity, status_id, string, is_private);
} else { } else {
controller.openNewMessageWindowInReplyTostatusIdwithString(entity, status_id, string); controller.openNewMessageWindowInReplyTostatusIdwithStringIsPrivate(entity, status_id, string, is_private);
} }
} }

View file

@ -138,9 +138,9 @@ function(jQuery, HostApp, Hmac, Cache) {
Paths.getURL(entity, "GET", function(resp) { Paths.getURL(entity, "GET", function(resp) {
if (resp.status >= 200 && resp.status < 300) { if (resp.status >= 200 && resp.status < 300) {
var div = document.createElement("div"); var doc = document.implementation.createHTMLDocument("");
div.innerHTML = resp.responseText; doc.documentElement.innerHTML = resp.responseText;
var links = $(div).find("link[rel='https://tent.io/rels/profile']"); var links = $(doc).find("link[rel='https://tent.io/rels/profile']");
if (links.length > 0) { if (links.length > 0) {
var href = links.get(0).href; var href = links.get(0).href;