<commit_before>Ext.define 'App.model.Message'

    extend: 'App.model.Base'

    fields: [
        { name:'id', type: 'int', useNull: true }
        { name:'source_id', type: 'int', useNull: true }
        { name:'source', type: 'auto' }
        { name:'source_type', type: 'auto' }
        { name:'sender', type: 'auto' }
        { name:'recipient', type: 'auto' }
        { name:'cc', type: 'auto' }
        { name:'subject', type: 'auto' }
        { name:'tracking_number', type: 'auto'  }
        { name:'message', type: 'auto'  }
        { name:'attach', type: 'bool', defaultValue: true }
        { name:'transmitted_at', type: 'date', dateFormat:'c' }
        { name:'created_at', type: 'date', persist: false, dateFormat:'c' }
        { name:'created_by_id', type: 'int', useNull: true }
    ]

    api_key: 'messages'

    toString:->
        'Message id ' + this.getId()

    associations: [
        { associatedName: 'attachments',  type: 'hasMany',   model: 'App.model.Attachment', foreignKey: 'message_id', primary_key: 'id' }
    ]

    mixins:
        polysrc: 'App.model.mixins.PolymorphicSource'


    defaultMessages:
        PurchaseOrder: new Ext.Template('Attached please find Purchase Order # {visible_id}\n\nThank You!',{ compiled: true})

    defaultSubjects:
        PurchaseOrder: new Ext.Template('Purchase Order # {visible_id}',{ compiled: true})

    setSource:(obj)->
        this.mixins.polysrc.setSource.call( this, obj)
        if ! this.get('message')
            this.set( 'message', @defaultMessages[ Util.baseClassName(obj) ].apply( obj.data ) )

        if ! this.get('subject')
            this.set( 'subject', @defaultSubjects[ Util.baseClassName(obj) ].apply( obj.data ) )

        this

    send:(options)->
        this.save({<commit_msg>Don't use deprecated api_key<commit_after>Ext.define 'App.model.Message'

    extend: 'App.model.Base'

    fields: [
        { name:'id', type: 'int', useNull: true }
        { name:'source_id', type: 'int', useNull: true }
        { name:'source', type: 'auto' }
        { name:'source_type', type: 'auto' }
        { name:'sender', type: 'auto' }
        { name:'recipient', type: 'auto' }
        { name:'cc', type: 'auto' }
        { name:'subject', type: 'auto' }
        { name:'tracking_number', type: 'auto'  }
        { name:'message', type: 'auto'  }
        { name:'attach', type: 'bool', defaultValue: true }
        { name:'transmitted_at', type: 'date', dateFormat:'c' }
        { name:'created_at', type: 'date', persist: false, dateFormat:'c' }
        { name:'created_by_id', type: 'int', useNull: true }
    ]

    proxy: App.Util.makeProxy( 'messages' )


    associations: [
        { associatedName: 'attachments',  type: 'hasMany',   model: 'App.model.Attachment', foreignKey: 'message_id', primary_key: 'id' }
    ]

    mixins:
        polysrc: 'App.model.mixins.PolymorphicSource'


    defaultMessages:
        PurchaseOrder: new Ext.Template('Attached please find Purchase Order # {visible_id}\n\nThank You!',{ compiled: true})

    defaultSubjects:
        PurchaseOrder: new Ext.Template('Purchase Order # {visible_id}',{ compiled: true})

    setSource:(obj)->
        this.mixins.polysrc.setSource.call( this, obj)
        if ! this.get('message')
            this.set( 'message', @defaultMessages[ Util.baseClassName(obj) ].apply( obj.data ) )

        if ! this.get('subject')
            this.set( 'subject', @defaultSubjects[ Util.baseClassName(obj) ].apply( obj.data ) )

        this

    send:(options)->
        this.save({
{'fraction_non_alphanumeric': 0.16817155756207675, 'fraction_numerical': 0.0, 'mean_word_length': 2.7394514767932487, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4264344', 'n_tokens_mistral': 1157, 'n_tokens_neox': 1121, 'n_words': 243}