'target_user is the user whose avatar_url is to be changed;
auth_user is the user attempting to make this change.'

@defer.inlineCallbacks
def set_avatar_url(self, target_user, requester, new_avatar_url, by_admin=False):

    if (not self.hs.is_mine(target_user)):
        raise SynapseError(400, 'User    is    not    hosted    on    this    Home    Server')
    if ((not by_admin) and (target_user != requester.user)):
        raise AuthError(400, "Cannot    set    another    user's    avatar_url")
    (yield self.store.set_profile_avatar_url(target_user.localpart, new_avatar_url))
    (yield self._update_join_states(requester))
