[Asterisk-code-review] res pjsip: Fix mwi subscribe replaces unsolicited type mismatch (asterisk[13])

Richard Mudgett asteriskteam at digium.com
Tue Aug 7 14:48:38 CDT 2018


Richard Mudgett has uploaded this change for review. ( https://gerrit.asterisk.org/9839


Change subject: res_pjsip: Fix mwi_subscribe_replaces_unsolicited type mismatch
......................................................................

res_pjsip: Fix mwi_subscribe_replaces_unsolicited type mismatch

ASTERISK-27988

Change-Id: Iccafdd0552ea8aaed647620fb14499f1bf341843
---
A contrib/ast-db-manage/config/versions/fe6592859b85_fix_mwi_subscribe_replaces_.py
M res/res_pjsip/pjsip_configuration.c
2 files changed, 39 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/39/9839/1

diff --git a/contrib/ast-db-manage/config/versions/fe6592859b85_fix_mwi_subscribe_replaces_.py b/contrib/ast-db-manage/config/versions/fe6592859b85_fix_mwi_subscribe_replaces_.py
new file mode 100644
index 0000000..0aa1791
--- /dev/null
+++ b/contrib/ast-db-manage/config/versions/fe6592859b85_fix_mwi_subscribe_replaces_.py
@@ -0,0 +1,38 @@
+"""Fix mwi_subscribe_replaces_unsolicited
+
+Revision ID: fe6592859b85
+Revises: 19b00bc19b7b
+Create Date: 2018-08-06 15:50:44.405534
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = 'fe6592859b85'
+down_revision = '19b00bc19b7b'
+
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.dialects.postgresql import ENUM
+
+YESNO_NAME = 'yesno_values'
+YESNO_VALUES = ['yes', 'no']
+
+
+def upgrade():
+    ############################# Enums ##############################
+
+    # yesno_values have already been created, so use postgres enum object
+    # type to get around "already created" issue - works okay with mysql
+    yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
+
+    # Can't cast integers to YESNO_VALUES, so dropping and adding is required
+    op.drop_column('ps_endpoints', 'mwi_subscribe_replaces_unsolicited')
+    op.add_column('ps_endpoints', sa.Column('mwi_subscribe_replaces_unsolicited', yesno_values))
+
+
+def downgrade():
+    # Can't cast YENO_VALUES to Integers, so dropping and adding is required
+    if op.get_context().bind.dialect.name == 'mssql':
+        op.drop_constraint('ck_ps_endpoints_mwi_subscribe_replaces_unsolicited_yesno_values', 'ps_endpoints')
+    op.drop_column('ps_endpoints', 'mwi_subscribe_replaces_unsolicited')
+    op.add_column('ps_endpoints', sa.Column('mwi_subscribe_replaces_unsolicited', sa.Integer))
diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c
index 5a25cb6..b0eb2d4 100644
--- a/res/res_pjsip/pjsip_configuration.c
+++ b/res/res_pjsip/pjsip_configuration.c
@@ -1784,7 +1784,7 @@
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mailboxes", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, subscription.mwi.mailboxes));
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "voicemail_extension", "", voicemail_extension_handler, voicemail_extension_to_str, NULL, 0, 0);
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "aggregate_mwi", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, subscription.mwi.aggregate));
-	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mwi_subscribe_replaces_unsolicited", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, subscription.mwi.subscribe_replaces_unsolicited));
+	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mwi_subscribe_replaces_unsolicited", "no", OPT_YESNO_T, 1, FLDSET(struct ast_sip_endpoint, subscription.mwi.subscribe_replaces_unsolicited));
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "media_encryption", "no", media_encryption_handler, media_encryption_to_str, NULL, 0, 0);
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "use_avpf", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.use_avpf));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "force_avp", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.force_avp));

-- 
To view, visit https://gerrit.asterisk.org/9839
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iccafdd0552ea8aaed647620fb14499f1bf341843
Gerrit-Change-Number: 9839
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180807/78ca1f87/attachment.html>


More information about the asterisk-code-review mailing list