Skip to content

Commit 9e64f00

Browse files
authored
Merge branch 'main' into twilio-update
2 parents 2bea8b5 + 02dcea8 commit 9e64f00

File tree

21 files changed

+77
-62
lines changed

21 files changed

+77
-62
lines changed

CHANGELOG.md

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
v8.1.62 (2023-03-08)
2+
-------------------------
3+
* Small z-index tweak
4+
5+
v8.1.61 (2023-03-07)
6+
-------------------------
7+
* Tweak simulator placement in new ui
8+
9+
v8.1.60 (2023-03-07)
10+
-------------------------
11+
* Encourage users to try the new interface
12+
* Add lightbox for contact history
13+
14+
v8.1.59 (2023-03-07)
15+
-------------------------
16+
* Rework code depending on msg_type=I|F
17+
118
v8.1.58 (2023-03-07)
219
-------------------------
320
* Add missing channels migration

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
]
1010
},
1111
"dependencies": {
12-
"@nyaruka/flow-editor": "1.19.2",
13-
"@nyaruka/temba-components": "0.42.1",
12+
"@nyaruka/flow-editor": "1.19.3",
13+
"@nyaruka/temba-components": "0.43.0",
1414
"codemirror": "5.18.2",
1515
"colorette": "1.2.2",
1616
"fa-icons": "0.2.0",

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "temba"
3-
version = "8.1.58"
3+
version = "8.1.62"
44
description = "Hosted service for visually building interactive messaging applications"
55
authors = ["Nyaruka <[email protected]>"]
66
license = "AGPL-3"

static/css/temba-components.css

+2
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ html {
154154
--temba-charcount-summary-right: 0px;
155155
--temba-charcount-summary-bottom: 0px;
156156

157+
--color-automated: rgb(78,205,106);
158+
157159
}
158160

159161
temba-button {

temba/campaigns/views.py

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def form_valid(self, form):
116116

117117
class Read(SpaMixin, OrgObjPermsMixin, ContentMenuMixin, SmartReadView):
118118
slug_url_kwarg = "uuid"
119+
menu_path = "/campaign/active"
119120

120121
def derive_title(self):
121122
return self.object.name

temba/channels/tests.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,8 @@ def test_read(self):
553553
self.tel_channel.save()
554554

555555
# now let's create an ivr interaction
556-
self.create_incoming_msg(joe, "incoming ivr", channel=self.tel_channel, msg_type=Msg.TYPE_VOICE)
557-
self.create_outgoing_msg(joe, "outgoing ivr", channel=self.tel_channel, msg_type=Msg.TYPE_VOICE)
556+
self.create_incoming_msg(joe, "incoming ivr", channel=self.tel_channel, voice=True)
557+
self.create_outgoing_msg(joe, "outgoing ivr", channel=self.tel_channel, voice=True)
558558
response = self.fetch_protected(tel_channel_read_url, self.admin)
559559

560560
self.assertEqual(4, len(response.context["message_stats"]))
@@ -1567,15 +1567,15 @@ def test_daily_counts(self):
15671567
ChannelCount.objects.all().delete()
15681568

15691569
# incoming IVR
1570-
msg4 = self.create_incoming_msg(contact, "Test Message", msg_type=Msg.TYPE_VOICE)
1570+
msg4 = self.create_incoming_msg(contact, "Test Message", voice=True)
15711571
self.assertDailyCount(self.channel, 1, ChannelCount.INCOMING_IVR_TYPE, msg4.created_on.date())
15721572
msg4.delete()
15731573
self.assertDailyCount(self.channel, 1, ChannelCount.INCOMING_IVR_TYPE, msg4.created_on.date())
15741574

15751575
ChannelCount.objects.all().delete()
15761576

15771577
# outgoing ivr
1578-
msg5 = self.create_outgoing_msg(contact, "Real Voice", msg_type=Msg.TYPE_VOICE)
1578+
msg5 = self.create_outgoing_msg(contact, "Real Voice", voice=True)
15791579
self.assertDailyCount(self.channel, 1, ChannelCount.OUTGOING_IVR_TYPE, msg5.created_on.date())
15801580
msg5.delete()
15811581
self.assertDailyCount(self.channel, 1, ChannelCount.OUTGOING_IVR_TYPE, msg5.created_on.date())

temba/contacts/tests.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -2505,10 +2505,13 @@ def test_history_templatetags(self):
25052505
item = {"type": "call_started", "status": "F"}
25062506
self.assertEqual(history_class(item), "non-msg warning")
25072507

2508-
# inbound
2508+
# inbound (legacy msg_type)
25092509
item = {"type": "msg_received", "msg": {"text": "Hi"}, "msg_type": "I"}
25102510
self.assertEqual(history_icon(item), '<span class="glyph icon-bubble-user"></span>')
25112511

2512+
item = {"type": "msg_received", "msg": {"text": "Hi"}, "msg_type": "T"}
2513+
self.assertEqual(history_icon(item), '<span class="glyph icon-bubble-user"></span>')
2514+
25122515
# outgoing sent
25132516
item = {"type": "msg_created", "msg": {"text": "Hi"}, "status": "S"}
25142517
self.assertEqual(history_icon(item), '<span class="glyph icon-bubble-right"></span>')

temba/dashboard/tests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ def create_activity(self):
1616
self.create_outgoing_msg(joe, "Tea of coffee?")
1717
self.create_incoming_msg(joe, "Coffee")
1818
self.create_outgoing_msg(joe, "OK")
19-
self.create_outgoing_msg(joe, "Wanna hang?", msg_type="V")
20-
self.create_incoming_msg(joe, "Sure", msg_type="V")
19+
self.create_outgoing_msg(joe, "Wanna hang?", voice=True)
20+
self.create_incoming_msg(joe, "Sure", voice=True)
2121

2222
def test_dashboard_home(self):
2323
dashboard_url = reverse("dashboard.dashboard_home")

temba/mailroom/events.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def from_msg(cls, org: Org, user: User, obj: Msg) -> dict:
9090
"created_on": get_event_time(obj).isoformat(),
9191
"msg": _msg_in(obj),
9292
# additional properties
93-
"msg_type": obj.msg_type,
93+
"msg_type": Msg.TYPE_VOICE if obj.msg_type == Msg.TYPE_VOICE else Msg.TYPE_TEXT,
9494
"visibility": obj.visibility,
9595
"logs_url": logs_url,
9696
}

temba/mailroom/tests.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ def test_from_msg(self):
803803
"channel": {"uuid": str(self.channel.uuid), "name": "Test Channel"},
804804
"external_id": "12345",
805805
},
806-
"msg_type": "I",
806+
"msg_type": "T",
807807
"visibility": "V",
808808
"logs_url": None,
809809
},
@@ -826,7 +826,7 @@ def test_from_msg(self):
826826
"channel": {"uuid": str(self.channel.uuid), "name": "Test Channel"},
827827
"external_id": "12345",
828828
},
829-
"msg_type": "I",
829+
"msg_type": "T",
830830
"visibility": "D",
831831
"logs_url": None,
832832
},
@@ -849,7 +849,7 @@ def test_from_msg(self):
849849
"channel": {"uuid": str(self.channel.uuid), "name": "Test Channel"},
850850
"external_id": "12345",
851851
},
852-
"msg_type": "I",
852+
"msg_type": "T",
853853
"visibility": "X",
854854
"logs_url": None,
855855
},
@@ -919,7 +919,7 @@ def test_from_msg(self):
919919
Event.from_msg(self.org, self.admin, msg_out),
920920
)
921921

922-
ivr_out = self.create_outgoing_msg(contact1, "Hello", msg_type="V")
922+
ivr_out = self.create_outgoing_msg(contact1, "Hello", voice=True)
923923

924924
self.assertEqual(
925925
{

temba/msgs/models.py

+1-18
Original file line numberDiff line numberDiff line change
@@ -539,23 +539,6 @@ class Msg(models.Model):
539539
metadata = JSONAsTextField(null=True, default=dict)
540540
log_uuids = ArrayField(models.UUIDField(), null=True)
541541

542-
@classmethod
543-
def get_messages(cls, org, is_archived=False, direction=None, msg_type=None):
544-
messages = cls.objects.filter(org=org)
545-
546-
if is_archived: # pragma: needs cover
547-
messages = messages.filter(visibility=Msg.VISIBILITY_ARCHIVED)
548-
else:
549-
messages = messages.filter(visibility=Msg.VISIBILITY_VISIBLE)
550-
551-
if direction: # pragma: needs cover
552-
messages = messages.filter(direction=direction)
553-
554-
if msg_type: # pragma: needs cover
555-
messages = messages.filter(msg_type=msg_type)
556-
557-
return messages
558-
559542
@classmethod
560543
def fail_old_messages(cls): # pragma: needs cover
561544
"""
@@ -1181,7 +1164,7 @@ def _get_msg_batches(self, system_label, label, start_date, end_date):
11811164
elif label:
11821165
messages = label.get_messages()
11831166
else:
1184-
messages = Msg.get_messages(self.org)
1167+
messages = self.org.msgs.filter(visibility=Msg.VISIBILITY_VISIBLE)
11851168

11861169
messages = messages.filter(created_on__gte=start_date, created_on__lte=end_date)
11871170

temba/msgs/templatetags/sms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
def as_icon(contact_event):
2424
icon = "icon-bubble-dots-2 green"
2525
direction = getattr(contact_event, "direction", "O")
26-
msg_type = getattr(contact_event, "msg_type", "I")
26+
msg_type = getattr(contact_event, "msg_type", "T")
2727

2828
if hasattr(contact_event, "status"):
2929
status = contact_event.status

temba/msgs/tests.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,7 @@ def test_big_ids(self):
13291329
text="Hi there",
13301330
channel=self.channel,
13311331
status="H",
1332-
msg_type="I",
1332+
msg_type="T",
13331333
visibility="V",
13341334
created_on=timezone.now(),
13351335
)
@@ -1630,6 +1630,7 @@ def test_failed(self, mock_msg_resend):
16301630
self.assertNotIn("resend", response.context["actions"])
16311631

16321632
def test_filter(self):
1633+
flow = self.create_flow("Flow")
16331634
joe = self.create_contact("Joe Blow", phone="+250788000001")
16341635
frank = self.create_contact("Frank Blow", phone="250788000002")
16351636
billy = self.create_contact("Billy Bob", urns=["twitter:billy_bob"])
@@ -1645,7 +1646,7 @@ def test_filter(self):
16451646
msg3 = self.create_incoming_msg(billy, "test3")
16461647
msg4 = self.create_incoming_msg(joe, "test4", visibility=Msg.VISIBILITY_ARCHIVED)
16471648
msg5 = self.create_incoming_msg(joe, "test5", visibility=Msg.VISIBILITY_DELETED_BY_USER)
1648-
msg6 = self.create_incoming_msg(joe, "flow test", msg_type="F")
1649+
msg6 = self.create_incoming_msg(joe, "IVR test", flow=flow)
16491650

16501651
# apply the labels
16511652
label1.toggle_label([msg1, msg2], add=True)

temba/tests/base.py

+5-10
Original file line numberDiff line numberDiff line change
@@ -288,26 +288,21 @@ def create_incoming_msg(
288288
contact,
289289
text,
290290
channel=None,
291-
msg_type=None,
292291
attachments=(),
293292
status=Msg.STATUS_HANDLED,
294293
visibility=Msg.VISIBILITY_VISIBLE,
295294
created_on=None,
296295
external_id=None,
296+
voice=False,
297297
surveyor=False,
298298
flow=None,
299299
):
300-
assert not msg_type or status != Msg.STATUS_PENDING, "pending messages don't have a msg type"
301-
302-
if status == Msg.STATUS_HANDLED and not msg_type:
303-
msg_type = Msg.TYPE_INBOX
304-
305300
return self._create_msg(
306301
contact,
307302
text,
308303
Msg.DIRECTION_IN,
309304
channel=channel,
310-
msg_type=msg_type,
305+
msg_type=Msg.TYPE_VOICE if voice else Msg.TYPE_TEXT,
311306
attachments=attachments,
312307
quick_replies=None,
313308
status=status,
@@ -327,14 +322,14 @@ def create_outgoing_msg(
327322
contact,
328323
text,
329324
channel=None,
330-
msg_type=Msg.TYPE_TEXT,
331325
attachments=(),
332326
quick_replies=(),
333327
status=Msg.STATUS_SENT,
334328
created_on=None,
335329
created_by=None,
336330
sent_on=None,
337331
high_priority=False,
332+
voice=False,
338333
surveyor=False,
339334
next_attempt=None,
340335
failed_reason=None,
@@ -352,7 +347,7 @@ def create_outgoing_msg(
352347
text,
353348
Msg.DIRECTION_OUT,
354349
channel=channel,
355-
msg_type=msg_type,
350+
msg_type=Msg.TYPE_VOICE if voice else Msg.TYPE_TEXT,
356351
attachments=attachments,
357352
quick_replies=quick_replies,
358353
status=status,
@@ -471,7 +466,7 @@ def create_broadcast(
471466
text,
472467
Msg.DIRECTION_OUT,
473468
channel=None,
474-
msg_type=Msg.TYPE_INBOX,
469+
msg_type=Msg.TYPE_TEXT,
475470
attachments=(),
476471
quick_replies=(),
477472
status=msg_status,

temba/tests/engine.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,12 @@ def _handle_msg_created(self, event):
363363
contact=self.contact,
364364
contact_urn=self.contact.get_urn(),
365365
channel=Channel.objects.get(uuid=channel_ref["uuid"]) if channel_ref else None,
366-
direction="O",
366+
direction=Msg.DIRECTION_OUT,
367367
text=event["msg"]["text"],
368368
attachments=attachments,
369369
created_on=event["created_on"],
370-
msg_type="F",
371-
status="S",
370+
msg_type=Msg.TYPE_TEXT,
371+
status=Msg.STATUS_SENT,
372372
sent_on=event["created_on"],
373373
)
374374

temba/tickets/tests.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def assert_tickets(resp, tickets: list):
349349
"last_msg": {
350350
"text": "Hello?",
351351
"direction": "I",
352-
"type": "I",
352+
"type": "T",
353353
"created_on": matchers.ISODate(),
354354
"sender": None,
355355
"attachments": [],
@@ -370,7 +370,7 @@ def assert_tickets(resp, tickets: list):
370370
"last_msg": {
371371
"text": "We can help",
372372
"direction": "O",
373-
"type": "I",
373+
"type": "T",
374374
"created_on": matchers.ISODate(),
375375
"sender": {"id": self.admin.id, "email": "[email protected]"},
376376
"attachments": [],
@@ -391,7 +391,7 @@ def assert_tickets(resp, tickets: list):
391391
"last_msg": {
392392
"text": "We can help",
393393
"direction": "O",
394-
"type": "I",
394+
"type": "T",
395395
"created_on": matchers.ISODate(),
396396
"sender": {"id": self.admin.id, "email": "[email protected]"},
397397
"attachments": [],

templates/flows/flow_editor_spa.haml

+8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
height: 100%;
2828
}
2929

30+
.simulator {
31+
top: 59px !important;
32+
}
33+
34+
.revisions {
35+
top: 110px !important;
36+
}
37+
3038
#simulator-tab {
3139
margin-right: 17px;
3240
}

templates/orgs/login/login.haml

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
{% analytics_hook 'login' %}
1010

11+
:javascript
12+
document.cookie = "nav=2; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/;";
13+
1114
-blocktrans trimmed
1215
Please sign in with your email address and password.
1316

templates/spa_frame.haml

+3-1
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@
732732
.flex-grow
733733

734734
.folders
735-
%temba-menu#nav(class="{% if servicing %}{% endif%}" style="height:100%" endpoint="{% url 'orgs.org_menu' %}" onchange="handleMenuChanged(event)" -temba-button-clicked="handleMenuClicked(event)" -temba-ready="handleMenuReady")
735+
%temba-menu.relative.z-0#nav(class="{% if servicing %}{% endif%}" style="height:100%" endpoint="{% url 'orgs.org_menu' %}" onchange="handleMenuChanged(event)" -temba-button-clicked="handleMenuClicked(event)" -temba-ready="handleMenuReady")
736736
-block menu-header
737737

738738
.flex-grow.spa-container.flex.flex-col.initial-load
@@ -782,3 +782,5 @@
782782
Go back to the
783783
%span.linked(onclick="leaveNewInterface()" style="color:#43b1ff")<
784784
old interface
785+
786+
%temba-lightbox

templates/tickets/ticket_list_spa.haml

+1-1
Original file line numberDiff line numberDiff line change
@@ -323,4 +323,4 @@
323323
Sometimes an automated chatbot isn't enough. When your contacts need to chat with a real person, you can use the
324324
Open Ticket action to open a new ticket.
325325

326-
%temba-contact-chat.shadow(agent="{{request.user.email}}" -temba-refreshed="handleContactHistoryUpdated" -temba-content-changed="handleTicketUpdated" monitor="true" toolbar="true")
326+
%temba-contact-chat.shadow.mb-6(agent="{{request.user.email}}" -temba-refreshed="handleContactHistoryUpdated" -temba-content-changed="handleTicketUpdated" monitor="true" toolbar="true")

0 commit comments

Comments
 (0)