mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	This fixes a bug where the endpoint for editing bot users would allow an organization administrator to edit the full name of a bot user. A combination of this an another recently fixed bug made it possible for this process to set a `bot_owner` for a non-bot user; so we also include a migration to fix that for any users that might have had our model invariants corrupted in that way.
		
			
				
	
	
		
			25 lines
		
	
	
		
			889 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			889 B
		
	
	
	
		
			Python
		
	
	
	
	
	
# -*- coding: utf-8 -*-
 | 
						|
# Generated by Django 1.11.6 on 2018-04-03 01:52
 | 
						|
from __future__ import unicode_literals
 | 
						|
 | 
						|
from django.db import migrations
 | 
						|
from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor
 | 
						|
from django.db.migrations.state import StateApps
 | 
						|
 | 
						|
def migrate_fix_invalid_bot_owner_values(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
 | 
						|
    """Fixes UserProfile objects that incorrectly had a bot_owner set"""
 | 
						|
    UserProfile = apps.get_model('zerver', 'UserProfile')
 | 
						|
    UserProfile.objects.filter(is_bot=False).exclude(bot_owner=None).update(bot_owner=None)
 | 
						|
 | 
						|
class Migration(migrations.Migration):
 | 
						|
 | 
						|
    dependencies = [
 | 
						|
        ('zerver', '0153_remove_int_float_custom_fields'),
 | 
						|
    ]
 | 
						|
 | 
						|
    operations = [
 | 
						|
        migrations.RunPython(
 | 
						|
            migrate_fix_invalid_bot_owner_values,
 | 
						|
            reverse_code=migrations.RunPython.noop),
 | 
						|
    ]
 |