-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge the main branch into adjust-sending-rate-on-timeout.
- Loading branch information
Showing
17 changed files
with
327 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.1.0" | ||
__version__ = "1.4.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/smpp_gateway/migrations/0008_remove_mtmessage_mt_message_status_idx_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Generated by Django 4.2.16 on 2024-11-14 09:35 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("smpp_gateway", "0007_momessage_error_alter_momessage_status"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveIndex( | ||
model_name="mtmessage", | ||
name="mt_message_status_idx", | ||
), | ||
migrations.AddField( | ||
model_name="mtmessage", | ||
name="priority_flag", | ||
field=models.IntegerField( | ||
choices=[ | ||
(0, "Level 0 (lowest) priority"), | ||
(1, "Level 1 priority"), | ||
(2, "Level 2 priority"), | ||
(3, "Level 3 (highest) priority"), | ||
], | ||
null=True, | ||
verbose_name="priority flag", | ||
), | ||
), | ||
migrations.AddIndex( | ||
model_name="mtmessage", | ||
index=models.Index( | ||
models.F("status"), | ||
models.OrderBy( | ||
models.F("priority_flag"), descending=True, nulls_last=True | ||
), | ||
condition=models.Q(("status", "new")), | ||
name="mt_message_status_idx", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from rapidsms.messages.incoming import IncomingMessage | ||
from rapidsms.messages.outgoing import OutgoingMessage | ||
from rapidsms.router.blocking import BlockingRouter | ||
|
||
from smpp_gateway.models import MTMessage | ||
|
||
|
||
class PriorityIncomingMessage(IncomingMessage): | ||
default_priority_flag = MTMessage.PriorityFlag.LEVEL_2 | ||
|
||
def respond(self, text, **kwargs): | ||
fields = kwargs.get("fields", {}) | ||
if "priority_flag" not in fields: | ||
fields["priority_flag"] = self.default_priority_flag.value | ||
kwargs["fields"] = fields | ||
return super().respond(text, **kwargs) | ||
|
||
|
||
class PriorityOutgoingMessage(OutgoingMessage): | ||
default_priority_flag = MTMessage.PriorityFlag.LEVEL_1 | ||
|
||
def extra_backend_context(self): | ||
context = super().extra_backend_context() | ||
context["priority_flag"] = self.fields.get( | ||
"priority_flag", self.default_priority_flag.value | ||
) | ||
return context | ||
|
||
|
||
class PriorityBlockingRouter(BlockingRouter): | ||
incoming_message_class = PriorityIncomingMessage | ||
outgoing_message_class = PriorityOutgoingMessage | ||
|
||
def new_incoming_message(self, text, connections, class_=None, **kwargs): | ||
if class_ is None: | ||
class_ = self.incoming_message_class | ||
return super().new_incoming_message(text, connections, class_=class_, **kwargs) | ||
|
||
def new_outgoing_message(self, text, connections, class_=None, **kwargs): | ||
if class_ is None: | ||
class_ = self.outgoing_message_class | ||
return super().new_outgoing_message(text, connections, class_=class_, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.