zulip / python-zulip-api

Python library for the Zulip API.
https://zulip.com/api/
Apache License 2.0
359 stars 361 forks source link

creation of private streams #621

Open tdupu opened 4 years ago

tdupu commented 4 years ago

Both ways documented in the API to make private streams seem to not work.

Here is the documentation for updating a stream to make it private: https://zulipchat.com/api/update-stream

Here is the documentation for initially creating a private stream: https://zulipchat.com/api/create-stream

Here is some example code that tries to use both of these ways to create private streams:

`

make a group

groupsize=4 random_groups=chunk(registered,groupsize) streams = [] for j in range(len(random_groups)): stream_name = todays + ('topology stream %s' %j) prins = [x + "@uvm.edu" for x in random_groups[j]] result=admin_client.add_subscriptions( streams=[ {'name':stream_name, 'description': 'random stream for' + todays, 'is_private':True } ], principals = prins+['taylor.dupuy@gmail.com']

)

print(result)
stream_id = admin_client.get_stream_id(stream_name)

#set the streams to private
#request = {
#'stream_id': stream_id,
#'stream_post_policy': 2,
#'is_private': True
#}
#result = admin_client.update_stream(request)
#print(result)

streams.append({'stream_id':stream_id,'stream_name':stream_name})

`

results are

{'result': 'error', 'msg': 'Unexpected arguments: is_private', 'code': 'BAD_REQUEST'} {'result': 'error', 'msg': 'Unexpected arguments: is_private', 'code': 'BAD_REQUEST'}

`

make a group

groupsize=4 random_groups=chunk(registered,groupsize) streams = [] for j in range(len(random_groups)): stream_name = todays + ('topology stream %s' %j) prins = [x + "@uvm.edu" for x in random_groups[j]] result=admin_client.add_subscriptions( streams=[ {'name':stream_name, 'description': 'random stream for' + todays, 'invite_only':True } ], principals = prins+['taylor.dupuy@gmail.com']

)

print(result)
stream_id = admin_client.get_stream_id(stream_name)

#set the streams to private
#request = {
#'stream_id': stream_id,
#'stream_post_policy': 2,
#'is_private': True
#}
#result = admin_client.update_stream(request)
#print(result)

streams.append({'stream_id':stream_id,'stream_name':stream_name})

`

results in

{'result': 'error', 'msg': 'Unexpected arguments: invite_only', 'code': 'BAD_REQUEST'} {'result': 'error', 'msg': 'Unexpected arguments: invite_only', 'code': 'BAD_REQUEST'}

`

make a group

groupsize=4 random_groups=chunk(registered,groupsize) streams = [] for j in range(len(random_groups)): stream_name = todays + ('topology stream %s' %j) prins = [x + "@uvm.edu" for x in random_groups[j]] result=admin_client.add_subscriptions( streams=[ {'name':stream_name, 'description': 'random stream for' + todays } ], principals = prins+['taylor.dupuy@gmail.com']

)

print(result)
stream_id = admin_client.get_stream_id(stream_name)

#set the streams to private
request = {
'stream_id': stream_id,
'stream_post_policy': 2,
'is_private': True
}
result = admin_client.update_stream(request)
print(result)

streams.append({'stream_id':stream_id,'stream_name':stream_name})

`

results are

{'result': 'success', 'msg': '', 'subscribed': {'XXX@uvm.edu': ['2020-09-09topology stream 0'], 'XXX@uvm.edu': ['2020-09-09topology stream 0'], 'taylor.dupuy@gmail.com': ['2020-09-09topology stream 0'], 'XXX@uvm.edu': ['2020-09-09topology stream 0'], 'XXX@uvm.edu': ['2020-09-09topology stream 0']}, 'already_subscribed': {}} {'msg': 'Unexpected error from the server', 'result': 'http-error', 'status_code': 404} {'result': 'success', 'msg': '', 'subscribed': {'XXX@uvm.edu': ['2020-09-09topology stream 1'], 'taylor.dupuy@gmail.com': ['2020-09-09topology stream 1'], 'XXX@uvm.edu': ['2020-09-09topology stream 1'], 'XXX@uvm.edu': ['2020-09-09topology stream 1'], 'XXX@uvm.edu': ['2020-09-09topology stream 1']}, 'already_subscribed': {}} {'msg': 'Unexpected error from the server', 'result': 'http-error', 'status_code': 404}

This was all run from a jupyter notebook using my owner zuliprc file.

tdupu commented 4 years ago

(sorry about the formatting... something is off. I need to run to class. I will try and fix the formatting if I have time later. )

timabbott commented 4 years ago

@orientor @akashaviator @aero31aero can one of you try to reproduce this?

tdupu commented 4 years ago

I am also having issues with bots deleting streams. I just wanted to say this before I forget.

issue 1: bots can't delete streams as claimed in the API. Even with an owner zuliprc file.

issue 2: deletion doesn't really delete.

expected behavior: all conversation history gets deleted when you delete a stream.

actual behavior: create "stream 01" put people in it, have a conversation, then delete the stream. recreate "stream 01" and put new people in it. The OLD conversation from the previous people will still be in the stream.

I was making randomized groups for students when this happened and when I shuffled the students they got really confused because the conversations of the previous students was in the stream.

I will post some details if I get a chance but I thought an initial report was better than nothing. Maybe you want to put this in a new issue report (or two).

neiljp commented 4 years ago

@tdupu Regarding your first point, it's unclear if you mean the docs are incorrect and/or you are using a bot-owner or organization-owner zuliprc file. It does seem that the API delete-stream docs at https://zulip.com/api/delete-stream (and possibly other docs) don't specify whether an admin user is required or not.

You may have seen this, but this seems to indicate this is intended behavior: https://zulip.com/help/delete-a-stream

For more general discussion you may find it helpful to join https://chat.zulip.org :)