res_pjsip_session: add new flag use_callerid_contact

Add a new global flag to res_pjsip to allow the callerid to be used
as the username in the contact header.  This allows chan_pjsip to have
the same behavour as chan_sip

ASTERISK-28087 #close

Change-Id: I9a720e058323f6862a91c62f8a8c1a4b5c087b95
This commit is contained in:
Torrey Searle
2018-10-02 14:31:43 +02:00
parent dc52719cb9
commit bbbec2e95e
4 changed files with 82 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
"""pjsip add use_callerid_contact
Revision ID: 2bb1a85135ad
Revises: 7f85dd44c775
Create Date: 2018-10-18 15:13:40.462354
"""
# revision identifiers, used by Alembic.
revision = '2bb1a85135ad'
down_revision = '7f85dd44c775'
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():
# Create the new enum
ast_bool_values = ENUM(*AST_BOOL_VALUES, name=AST_BOOL_NAME, create_type=False)
if op.get_context().bind.dialect.name == 'postgresql':
ast_bool_values.create(op.get_bind(), checkfirst=False)
op.add_column('ps_globals', sa.Column('use_callerid_contact', ast_bool_values))
def downgrade():
if op.get_context().bind.dialect.name == 'mssql':
op.drop_constraint('ck_ps_globals_use_callerid_contact_ast_bool_values','ps_globals')
op.drop_column('ps_globals', 'use_callerid_contact')
if op.get_context().bind.dialect.name == 'postgresql':
ENUM(name=AST_BOOL_NAME).drop(op.get_bind(), checkfirst=False)