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

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

View file

@ -171,7 +171,7 @@ function(jQuery, Paths, URI, HostApp, Cache) {
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;
}
@ -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) {
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 {
@ -415,7 +415,7 @@ function(jQuery, Paths, URI, HostApp, Cache) {
"type": "https://tent.io/types/post/status/v0.1.0",
"published_at": parseInt(new Date().getTime() / 1000, 10),
"permissions": {
"public": true
"public": !is_private
},
"content": {
"text": content,
@ -430,6 +430,15 @@ function(jQuery, Paths, URI, HostApp, Cache) {
if (mentions.length > 0) {
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));
@ -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>");
}
Core.prototype.replyTo = function(entity, status_id, mentions) {
Core.prototype.replyTo = function(entity, status_id, mentions, is_private) {
var string = "^" + entity.replace("https://", "") + " ";
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 + " ";
}
HostApp.openNewMessageWidow(entity, status_id, string);
HostApp.openNewMessageWidow(entity, status_id, string, is_private);
}
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") {
controller.openNewMessageWindowInReplyTo_statusId_withString_(entity, status_id, string);
controller.openNewMessageWindowInReplyTo_statusId_withString_isPrivate_(entity, status_id, string, is_private);
} 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) {
if (resp.status >= 200 && resp.status < 300) {
var div = document.createElement("div");
div.innerHTML = resp.responseText;
var links = $(div).find("link[rel='https://tent.io/rels/profile']");
var doc = document.implementation.createHTMLDocument("");
doc.documentElement.innerHTML = resp.responseText;
var links = $(doc).find("link[rel='https://tent.io/rels/profile']");
if (links.length > 0) {
var href = links.get(0).href;