res_pjsip: add option to enable ContactStatus event when contact is updated

The commit I2f97ebfa79969a36a97bb7b9afd5b6268cf1a07d removed sending out
the ContactStatus AMI event when a contact is updated.
Thist change broke things which rely on old behavior.

This patch adds a new PJSIP global configuration option
'send_contact_status_on_update_registration' to be able to preserve old
ContactStatus behavior.
By default new behavior, i.e. the ContactStatus event will not be sent when a
device refreshes its registration.

Change-Id: I706adf7584e7077eb6bde6d9799ca408bc82ce46
This commit is contained in:
Alexei Gradinari
2018-12-18 14:47:36 -05:00
parent 9b57199a7a
commit 7f22c9f4b7
7 changed files with 136 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
"""pjsip add send_contact_status_on_update_registration
Revision ID: 0838f8db6a61
Revises: 1ac563b350a8
Create Date: 2018-12-18 14:45:07.811415
"""
# revision identifiers, used by Alembic.
revision = '0838f8db6a61'
down_revision = '1ac563b350a8'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import ENUM
AST_BOOL_NAME = 'ast_bool_values'
# We'll just ignore the n/y and f/t abbreviations as Asterisk does not write
# those aliases.
AST_BOOL_VALUES = [ '0', '1',
'off', 'on',
'false', 'true',
'no', 'yes' ]
def upgrade():
############################# Enums ##############################
# ast_bool_values has already been created, so use postgres enum object
# type to get around "already created" issue - works okay with mysql
ast_bool_values = ENUM(*AST_BOOL_VALUES, name=AST_BOOL_NAME, create_type=False)
op.add_column('ps_globals', sa.Column('send_contact_status_on_update_registration', ast_bool_values))
def downgrade():
if op.get_context().bind.dialect.name == 'mssql':
op.drop_constraint('ck_ps_globals_send_contact_status_on_update_registration_ast_bool_values', 'ps_globals')
op.drop_column('ps_globals', 'send_contact_status_on_update_registration')