mirror of https://github.com/zulip/zulip.git
Rename instance to subject.
(imported from commit 6b4693da03f106448c137cf81cf9801cac44f2b8)
This commit is contained in:
parent
8dca315a18
commit
ac3f4393ff
|
@ -66,8 +66,8 @@ def send_humbug(zeph):
|
||||||
zeph["sender"] = compute_humbug_username(zeph["sender"])
|
zeph["sender"] = compute_humbug_username(zeph["sender"])
|
||||||
zeph['fullname'] = username_to_fullname(zeph['sender'])
|
zeph['fullname'] = username_to_fullname(zeph['sender'])
|
||||||
zeph['shortname'] = zeph['sender'].split('@')[0]
|
zeph['shortname'] = zeph['sender'].split('@')[0]
|
||||||
if "instance" in zeph:
|
if "subject" in zeph:
|
||||||
zeph["instance"] = zeph["instance"][:30]
|
zeph["subject"] = zeph["subject"][:30]
|
||||||
|
|
||||||
for key in zeph.keys():
|
for key in zeph.keys():
|
||||||
if isinstance(zeph[key], unicode):
|
if isinstance(zeph[key], unicode):
|
||||||
|
@ -157,7 +157,7 @@ def process_loop(log):
|
||||||
'time' : str(notice.time),
|
'time' : str(notice.time),
|
||||||
'sender' : sender,
|
'sender' : sender,
|
||||||
'stream' : notice.cls.lower(),
|
'stream' : notice.cls.lower(),
|
||||||
'instance' : notice.instance.lower(),
|
'subject' : notice.instance.lower(),
|
||||||
'zsig' : zsig, # logged here but not used by app
|
'zsig' : zsig, # logged here but not used by app
|
||||||
'content' : body }
|
'content' : body }
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ def forward_to_zephyr(message):
|
||||||
if message['type'] == "stream":
|
if message['type'] == "stream":
|
||||||
zeph = zephyr.ZNotice(sender=message["sender_email"].replace("mit.edu", "ATHENA.MIT.EDU"),
|
zeph = zephyr.ZNotice(sender=message["sender_email"].replace("mit.edu", "ATHENA.MIT.EDU"),
|
||||||
auth=True, cls=message["display_recipient"],
|
auth=True, cls=message["display_recipient"],
|
||||||
instance=message["instance"])
|
instance=message["subject"])
|
||||||
body = "%s\0%s" % (zsig, wrapped_content)
|
body = "%s\0%s" % (zsig, wrapped_content)
|
||||||
zeph.setmessage(body)
|
zeph.setmessage(body)
|
||||||
zeph.send()
|
zeph.send()
|
||||||
|
|
|
@ -39,10 +39,10 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr id="stream-message">
|
<tr id="stream-message">
|
||||||
<td colspan="2" class="message_newstyle_stream">
|
<td colspan="2" class="message_newstyle_stream">
|
||||||
<input type="text" class="recipient_box" name="stream" id="stream" onchange="focus_on('instance')" value="" placeholder="Stream" autocomplete="off"/>
|
<input type="text" class="recipient_box" name="stream" id="stream" onchange="focus_on('subject')" value="" placeholder="Stream" autocomplete="off"/>
|
||||||
</td>
|
</td>
|
||||||
<td class="message_newstyle_instance">
|
<td class="message_newstyle_subject">
|
||||||
<input type="text" class="recipient_box" name="instance" id="instance" onchange="focus_on('new_message_content')" value="" placeholder="Subject" autocomplete="off"/>
|
<input type="text" class="recipient_box" name="subject" id="subject" onchange="focus_on('new_message_content')" value="" placeholder="Subject" autocomplete="off"/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr id="personal-message">
|
<tr id="personal-message">
|
||||||
|
|
|
@ -22,7 +22,7 @@ var globals =
|
||||||
|
|
||||||
// narrow.js
|
// narrow.js
|
||||||
+ ' narrowed show_all_messages'
|
+ ' narrowed show_all_messages'
|
||||||
+ ' narrow_all_personals narrow_by_recipient narrow_instance'
|
+ ' narrow_all_personals narrow_by_recipient narrow_subject'
|
||||||
|
|
||||||
// setup.js
|
// setup.js
|
||||||
+ ' loading_spinner templates'
|
+ ' loading_spinner templates'
|
||||||
|
@ -38,7 +38,7 @@ var globals =
|
||||||
|
|
||||||
// zephyr.js
|
// zephyr.js
|
||||||
+ ' message_array message_dict'
|
+ ' message_array message_dict'
|
||||||
+ ' status_classes clear_table add_to_table instance_list'
|
+ ' status_classes clear_table add_to_table subject_list'
|
||||||
+ ' keep_pointer_in_view move_pointer_at_page_top_and_bottom'
|
+ ' keep_pointer_in_view move_pointer_at_page_top_and_bottom'
|
||||||
+ ' respond_to_message'
|
+ ' respond_to_message'
|
||||||
+ ' select_message select_message_by_id'
|
+ ' select_message select_message_by_id'
|
||||||
|
|
|
@ -45,7 +45,7 @@ def process_push(oldrev, newrev, refname):
|
||||||
message_data = {
|
message_data = {
|
||||||
"type": "stream",
|
"type": "stream",
|
||||||
"stream": "test" if refname == "refs/heads/test-post-receive" else "devel",
|
"stream": "test" if refname == "refs/heads/test-post-receive" else "devel",
|
||||||
"instance": "commits",
|
"subject": "commits",
|
||||||
"content": "The following commits were just pushed to `%s`:\n\n"
|
"content": "The following commits were just pushed to `%s`:\n\n"
|
||||||
% (refname.replace("refs/heads/", ""),) + commits,
|
% (refname.replace("refs/heads/", ""),) + commits,
|
||||||
"recipient": "tabbott@humbughq.com",
|
"recipient": "tabbott@humbughq.com",
|
||||||
|
|
|
@ -25,9 +25,9 @@
|
||||||
class="message_label_clickable message_newstyle_stream"
|
class="message_label_clickable message_newstyle_stream"
|
||||||
onclick="select_message_by_id({{id}}); narrow_stream();"
|
onclick="select_message_by_id({{id}}); narrow_stream();"
|
||||||
title="{{display_recipient}}">{{display_recipient}}</td>
|
title="{{display_recipient}}">{{display_recipient}}</td>
|
||||||
<td class="message_label_clickable message_newstyle_instance"
|
<td class="message_label_clickable message_newstyle_subject"
|
||||||
onclick="select_message_by_id({{id}}); narrow_instance();"
|
onclick="select_message_by_id({{id}}); narrow_subject();"
|
||||||
title="{{instance}}">{{instance}}</td>
|
title="{{subject}}">{{subject}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{else}}
|
{{else}}
|
||||||
<tr class="recipient_row">
|
<tr class="recipient_row">
|
||||||
|
|
|
@ -238,7 +238,7 @@ def restore_saved_messages():
|
||||||
type_hash = {"stream": Recipient.STREAM, "huddle": Recipient.HUDDLE, "personal": Recipient.PERSONAL}
|
type_hash = {"stream": Recipient.STREAM, "huddle": Recipient.HUDDLE, "personal": Recipient.PERSONAL}
|
||||||
message.type = type_hash[old_message["type"]]
|
message.type = type_hash[old_message["type"]]
|
||||||
message.content = old_message["content"]
|
message.content = old_message["content"]
|
||||||
message.instance = old_message["instance"]
|
message.subject = old_message["subject"]
|
||||||
message.pub_date = datetime.datetime.utcfromtimestamp(float(old_message["timestamp"])).replace(tzinfo=utc)
|
message.pub_date = datetime.datetime.utcfromtimestamp(float(old_message["timestamp"])).replace(tzinfo=utc)
|
||||||
|
|
||||||
if message.type == Recipient.PERSONAL:
|
if message.type == Recipient.PERSONAL:
|
||||||
|
@ -267,10 +267,10 @@ def restore_saved_messages():
|
||||||
|
|
||||||
# Create some test messages, including:
|
# Create some test messages, including:
|
||||||
# - multiple streams
|
# - multiple streams
|
||||||
# - multiple instances per stream
|
# - multiple subjects per stream
|
||||||
# - multiple huddles
|
# - multiple huddles
|
||||||
# - multiple personals converastions
|
# - multiple personals converastions
|
||||||
# - multiple messages per instance
|
# - multiple messages per subject
|
||||||
# - both single and multi-line content
|
# - both single and multi-line content
|
||||||
def send_messages(data):
|
def send_messages(data):
|
||||||
(tot_messages, personals_pairs, options, output) = data
|
(tot_messages, personals_pairs, options, output) = data
|
||||||
|
@ -310,7 +310,7 @@ def send_messages(data):
|
||||||
personals_pair = saved_data
|
personals_pair = saved_data
|
||||||
random.shuffle(personals_pair)
|
random.shuffle(personals_pair)
|
||||||
elif message_type == Recipient.STREAM:
|
elif message_type == Recipient.STREAM:
|
||||||
message.instance = saved_data
|
message.subject = saved_data
|
||||||
message.recipient = get_recipient_by_id(recipient_id)
|
message.recipient = get_recipient_by_id(recipient_id)
|
||||||
elif message_type == Recipient.HUDDLE:
|
elif message_type == Recipient.HUDDLE:
|
||||||
message.recipient = get_recipient_by_id(recipient_id)
|
message.recipient = get_recipient_by_id(recipient_id)
|
||||||
|
@ -338,8 +338,8 @@ def send_messages(data):
|
||||||
# Pick a random subscriber to the stream
|
# Pick a random subscriber to the stream
|
||||||
message.sender = random.choice(Subscription.objects.filter(
|
message.sender = random.choice(Subscription.objects.filter(
|
||||||
recipient=message.recipient)).userprofile
|
recipient=message.recipient)).userprofile
|
||||||
message.instance = stream.name + str(random.randint(1, 3))
|
message.subject = stream.name + str(random.randint(1, 3))
|
||||||
saved_data = message.instance
|
saved_data = message.subject
|
||||||
|
|
||||||
message.pub_date = datetime.datetime.utcnow().replace(tzinfo=utc)
|
message.pub_date = datetime.datetime.utcnow().replace(tzinfo=utc)
|
||||||
do_send_message(message)
|
do_send_message(message)
|
||||||
|
|
|
@ -17,7 +17,7 @@ md_engine = markdown.Markdown(
|
||||||
|
|
||||||
def get_display_recipient(recipient):
|
def get_display_recipient(recipient):
|
||||||
"""
|
"""
|
||||||
recipient: an instance of Recipient.
|
recipient: an subject of Recipient.
|
||||||
|
|
||||||
returns: an appropriate string describing the recipient (the stream
|
returns: an appropriate string describing the recipient (the stream
|
||||||
name, for a stream, or the email, for a user).
|
name, for a stream, or the email, for a user).
|
||||||
|
@ -36,7 +36,7 @@ def get_display_recipient(recipient):
|
||||||
|
|
||||||
def get_log_recipient(recipient):
|
def get_log_recipient(recipient):
|
||||||
"""
|
"""
|
||||||
recipient: an instance of Recipient.
|
recipient: an subject of Recipient.
|
||||||
|
|
||||||
returns: an appropriate string describing the recipient (the stream
|
returns: an appropriate string describing the recipient (the stream
|
||||||
name, for a stream, or the email, for a user).
|
name, for a stream, or the email, for a user).
|
||||||
|
@ -197,13 +197,13 @@ class Recipient(models.Model):
|
||||||
class Message(models.Model):
|
class Message(models.Model):
|
||||||
sender = models.ForeignKey(UserProfile)
|
sender = models.ForeignKey(UserProfile)
|
||||||
recipient = models.ForeignKey(Recipient)
|
recipient = models.ForeignKey(Recipient)
|
||||||
instance = models.CharField(max_length=30)
|
subject = models.CharField(max_length=30)
|
||||||
content = models.TextField()
|
content = models.TextField()
|
||||||
pub_date = models.DateTimeField('date published')
|
pub_date = models.DateTimeField('date published')
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
display_recipient = get_display_recipient(self.recipient)
|
display_recipient = get_display_recipient(self.recipient)
|
||||||
return "<Message: %s / %s / %r>" % (display_recipient, self.instance, self.sender)
|
return "<Message: %s / %s / %r>" % (display_recipient, self.subject, self.sender)
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.__repr__()
|
return self.__repr__()
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ class Message(models.Model):
|
||||||
'type' : self.recipient.type_name(),
|
'type' : self.recipient.type_name(),
|
||||||
'display_recipient': get_display_recipient(self.recipient),
|
'display_recipient': get_display_recipient(self.recipient),
|
||||||
'recipient_id' : self.recipient.id,
|
'recipient_id' : self.recipient.id,
|
||||||
'instance' : self.instance,
|
'subject' : self.subject,
|
||||||
'content' : content,
|
'content' : content,
|
||||||
'timestamp' : calendar.timegm(self.pub_date.timetuple()),
|
'timestamp' : calendar.timegm(self.pub_date.timetuple()),
|
||||||
'gravatar_hash' : hashlib.md5(self.sender.user.email.lower()).hexdigest(),
|
'gravatar_hash' : hashlib.md5(self.sender.user.email.lower()).hexdigest(),
|
||||||
|
@ -247,7 +247,7 @@ class Message(models.Model):
|
||||||
'sender_short_name': self.sender.full_name,
|
'sender_short_name': self.sender.full_name,
|
||||||
'type' : self.recipient.type_name(),
|
'type' : self.recipient.type_name(),
|
||||||
'recipient' : get_log_recipient(self.recipient),
|
'recipient' : get_log_recipient(self.recipient),
|
||||||
'instance' : self.instance,
|
'subject' : self.subject,
|
||||||
'content' : self.content,
|
'content' : self.content,
|
||||||
'timestamp' : self.pub_date.strftime("%s"),
|
'timestamp' : self.pub_date.strftime("%s"),
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,8 @@ function compose_stream_name() {
|
||||||
return $.trim($("#stream").val());
|
return $.trim($("#stream").val());
|
||||||
}
|
}
|
||||||
|
|
||||||
function compose_instance() {
|
function compose_subject() {
|
||||||
return $.trim($("#instance").val());
|
return $.trim($("#subject").val());
|
||||||
}
|
}
|
||||||
|
|
||||||
function compose_message() {
|
function compose_message() {
|
||||||
|
@ -112,8 +112,8 @@ function validate_stream_message() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compose_instance() === "") {
|
if (compose_subject() === "") {
|
||||||
compose_error("Please specify an instance", $("#instance"));
|
compose_error("Please specify an subject", $("#subject"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ var keydown_handler = process_hotkey;
|
||||||
|
|
||||||
var goto_hotkeys = {
|
var goto_hotkeys = {
|
||||||
99: narrow_by_recipient, // 'c'
|
99: narrow_by_recipient, // 'c'
|
||||||
105: narrow_instance, // 'i'
|
105: narrow_subject, // 'i'
|
||||||
112: narrow_all_personals, // 'p'
|
112: narrow_all_personals, // 'p'
|
||||||
97: show_all_messages, // 'a'
|
97: show_all_messages, // 'a'
|
||||||
27: hide_compose // Esc
|
27: hide_compose // Esc
|
||||||
|
|
|
@ -67,16 +67,16 @@ function narrow_stream() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function narrow_instance() {
|
function narrow_subject() {
|
||||||
var original = message_dict[selected_message_id];
|
var original = message_dict[selected_message_id];
|
||||||
if (original.type !== 'stream')
|
if (original.type !== 'stream')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var message = original.display_recipient + " | " + original.instance;
|
var message = original.display_recipient + " | " + original.subject;
|
||||||
do_narrow(message, function (other) {
|
do_narrow(message, function (other) {
|
||||||
return (other.type === 'stream' &&
|
return (other.type === 'stream' &&
|
||||||
original.recipient_id === other.recipient_id &&
|
original.recipient_id === other.recipient_id &&
|
||||||
original.instance === other.instance);
|
original.subject === other.subject);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ var autocomplete_needs_update = false;
|
||||||
|
|
||||||
function update_autocomplete() {
|
function update_autocomplete() {
|
||||||
stream_list.sort();
|
stream_list.sort();
|
||||||
instance_list.sort();
|
subject_list.sort();
|
||||||
people_list.sort();
|
people_list.sort();
|
||||||
|
|
||||||
// limit number of items so the list doesn't fall off the screen
|
// limit number of items so the list doesn't fall off the screen
|
||||||
|
@ -83,8 +83,8 @@ function update_autocomplete() {
|
||||||
source: stream_list,
|
source: stream_list,
|
||||||
items: 3
|
items: 3
|
||||||
});
|
});
|
||||||
$( "#instance" ).typeahead({
|
$( "#subject" ).typeahead({
|
||||||
source: instance_list,
|
source: subject_list,
|
||||||
items: 2
|
items: 2
|
||||||
});
|
});
|
||||||
$( "#huddle_recipient" ).typeahead({
|
$( "#huddle_recipient" ).typeahead({
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
var message_array = [];
|
var message_array = [];
|
||||||
var message_dict = {};
|
var message_dict = {};
|
||||||
var instance_list = [];
|
var subject_list = [];
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
var i;
|
var i;
|
||||||
|
@ -118,10 +118,10 @@ function respond_to_message(reply_type) {
|
||||||
message = message_dict[selected_message_id];
|
message = message_dict[selected_message_id];
|
||||||
if (message.type === "stream") {
|
if (message.type === "stream") {
|
||||||
$("#stream").val(message.display_recipient);
|
$("#stream").val(message.display_recipient);
|
||||||
$("#instance").val(message.instance);
|
$("#subject").val(message.subject);
|
||||||
} else {
|
} else {
|
||||||
$("#stream").val("");
|
$("#stream").val("");
|
||||||
$("#instance").val("");
|
$("#subject").val("");
|
||||||
}
|
}
|
||||||
$("#huddle_recipient").val(message.reply_to);
|
$("#huddle_recipient").val(message.reply_to);
|
||||||
if (reply_type === "personal" && message.type === "huddle") {
|
if (reply_type === "personal" && message.type === "huddle") {
|
||||||
|
@ -209,7 +209,7 @@ function same_recipient(a, b) {
|
||||||
return a.reply_to === b.reply_to;
|
return a.reply_to === b.reply_to;
|
||||||
case 'stream':
|
case 'stream':
|
||||||
return (a.recipient_id === b.recipient_id) &&
|
return (a.recipient_id === b.recipient_id) &&
|
||||||
(a.instance === b.instance);
|
(a.subject === b.subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
// should never get here
|
// should never get here
|
||||||
|
@ -266,8 +266,8 @@ function add_to_table(messages, table_name, filter_function, where) {
|
||||||
// messages, in order to collapse properly.
|
// messages, in order to collapse properly.
|
||||||
//
|
//
|
||||||
// This means we redraw the entire view on each update when narrowed by
|
// This means we redraw the entire view on each update when narrowed by
|
||||||
// instance, which could be a problem down the line. For now we hope
|
// subject, which could be a problem down the line. For now we hope
|
||||||
// that instance views will not be very big.
|
// that subject views will not be very big.
|
||||||
|
|
||||||
var top_group = message_groups[table_name][0];
|
var top_group = message_groups[table_name][0];
|
||||||
var top_messages = [];
|
var top_messages = [];
|
||||||
|
@ -366,8 +366,8 @@ function add_message_metadata(dummy, message) {
|
||||||
switch (message.type) {
|
switch (message.type) {
|
||||||
case 'stream':
|
case 'stream':
|
||||||
message.is_stream = true;
|
message.is_stream = true;
|
||||||
if ($.inArray(message.instance, instance_list) === -1) {
|
if ($.inArray(message.subject, subject_list) === -1) {
|
||||||
instance_list.push(message.instance);
|
subject_list.push(message.subject);
|
||||||
autocomplete_needs_update = true;
|
autocomplete_needs_update = true;
|
||||||
}
|
}
|
||||||
message.reply_to = message.sender_email;
|
message.reply_to = message.sender_email;
|
||||||
|
|
|
@ -59,7 +59,7 @@ td.pointer {
|
||||||
.ztable_col2 { /* pointer */
|
.ztable_col2 { /* pointer */
|
||||||
width: 2px;
|
width: 2px;
|
||||||
}
|
}
|
||||||
.ztable_col3 { /* instancename */
|
.ztable_col3 { /* subjectname */
|
||||||
width: 85%;
|
width: 85%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ td.pointer {
|
||||||
border: 1px solid grey;
|
border: 1px solid grey;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message_newstyle_instance {
|
.message_newstyle_subject {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
|
|
|
@ -56,7 +56,7 @@ class AuthedTestCase(TestCase):
|
||||||
recipient = Stream.objects.get(name=recipient_name, realm=sender.realm)
|
recipient = Stream.objects.get(name=recipient_name, realm=sender.realm)
|
||||||
recipient = Recipient.objects.get(type_id=recipient.id, type=message_type)
|
recipient = Recipient.objects.get(type_id=recipient.id, type=message_type)
|
||||||
pub_date = datetime.datetime.utcnow().replace(tzinfo=utc)
|
pub_date = datetime.datetime.utcnow().replace(tzinfo=utc)
|
||||||
do_send_message(Message(sender=sender, recipient=recipient, instance="test", pub_date=pub_date),
|
do_send_message(Message(sender=sender, recipient=recipient, subject="test", pub_date=pub_date),
|
||||||
synced_from_mit=True)
|
synced_from_mit=True)
|
||||||
|
|
||||||
def users_subscribed_to_stream(self, stream_name, realm_domain):
|
def users_subscribed_to_stream(self, stream_name, realm_domain):
|
||||||
|
@ -319,7 +319,7 @@ class MessagePOSTTest(AuthedTestCase):
|
||||||
result = self.client.post("/send_message/", {"type": "stream",
|
result = self.client.post("/send_message/", {"type": "stream",
|
||||||
"stream": "Verona",
|
"stream": "Verona",
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"instance": "Test instance"})
|
"subject": "Test subject"})
|
||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
|
|
||||||
def test_message_to_nonexistent_stream(self):
|
def test_message_to_nonexistent_stream(self):
|
||||||
|
@ -332,7 +332,7 @@ class MessagePOSTTest(AuthedTestCase):
|
||||||
result = self.client.post("/send_message/", {"type": "stream",
|
result = self.client.post("/send_message/", {"type": "stream",
|
||||||
"stream": "nonexistent_stream",
|
"stream": "nonexistent_stream",
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"instance": "Test instance"})
|
"subject": "Test subject"})
|
||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
self.assertTrue(Stream.objects.filter(name="nonexistent_stream"))
|
self.assertTrue(Stream.objects.filter(name="nonexistent_stream"))
|
||||||
|
|
||||||
|
|
|
@ -357,16 +357,16 @@ def send_message_backend(request, user_profile, sender):
|
||||||
if message_type_name == 'stream':
|
if message_type_name == 'stream':
|
||||||
if "stream" not in request.POST:
|
if "stream" not in request.POST:
|
||||||
return json_error("Missing stream")
|
return json_error("Missing stream")
|
||||||
if "instance" not in request.POST:
|
if "subject" not in request.POST:
|
||||||
return json_error("Missing instance")
|
return json_error("Missing subject")
|
||||||
stream_name = strip_html(request.POST['stream']).strip()
|
stream_name = strip_html(request.POST['stream']).strip()
|
||||||
instance_name = strip_html(request.POST['instance']).strip()
|
subject_name = strip_html(request.POST['subject']).strip()
|
||||||
|
|
||||||
if not valid_stream_name(stream_name):
|
if not valid_stream_name(stream_name):
|
||||||
return json_error("Invalid stream name")
|
return json_error("Invalid stream name")
|
||||||
## FIXME: Commented out temporarily while we figure out what we want
|
## FIXME: Commented out temporarily while we figure out what we want
|
||||||
# if not valid_stream_name(instance_name):
|
# if not valid_stream_name(subject_name):
|
||||||
# return json_error("Invalid instance name")
|
# return json_error("Invalid subject name")
|
||||||
|
|
||||||
stream = create_stream_if_needed(user_profile.realm, stream_name)
|
stream = create_stream_if_needed(user_profile.realm, stream_name)
|
||||||
recipient = Recipient.objects.get(type_id=stream.id, type=Recipient.STREAM)
|
recipient = Recipient.objects.get(type_id=stream.id, type=Recipient.STREAM)
|
||||||
|
@ -409,7 +409,7 @@ def send_message_backend(request, user_profile, sender):
|
||||||
message.content = strip_html(request.POST['content'])
|
message.content = strip_html(request.POST['content'])
|
||||||
message.recipient = recipient
|
message.recipient = recipient
|
||||||
if message_type_name == 'stream':
|
if message_type_name == 'stream':
|
||||||
message.instance = instance_name
|
message.subject = subject_name
|
||||||
if 'time' in request.POST:
|
if 'time' in request.POST:
|
||||||
# Forged messages come with a timestamp
|
# Forged messages come with a timestamp
|
||||||
message.pub_date = datetime.datetime.utcfromtimestamp(float(request.POST['time'])).replace(tzinfo=utc)
|
message.pub_date = datetime.datetime.utcfromtimestamp(float(request.POST['time'])).replace(tzinfo=utc)
|
||||||
|
|
Loading…
Reference in New Issue