Labs/Bespin/DesignDocs/Collaboration/Detail
This is a list of all the commands that I'm planning on introducing, along with a semi-formal syntax for the command. This may seem overly formal, but it's the only reliable way I know to make sure I actually understand the implications of all the actions.
The command line syntax includes things to {lookup}. The looked up value will typically be turned into an integer id to be used in the SQL which we need to make the command work. The syntax also includes choices: (choice1|choice2) and some parts are [optional].
Where I've used capitals, e.g. USER, it related to the id looked up from {user}. CURRENT is the user.id of the current user.
Contents
Network manipulation
follow
List the users that the current user follows
Syntax:
follow
Actions:
- GET /network/followers
- SELECT users.username FROM users, connections WHERE connections.followed_id=CURRENT AND connections.following_id=users.id;
- Return 200 [ "user1", "user2" ]
follow {user}
Add a user to the list of users followed by the current user
Syntax:
follow {user} [{user} ...]
Actions:
- POST /network/follow
[ "{user1}", "{user2}", ...] - INSERT INTO connections (followed_id, following_id) VALUES (USER, CURRENT);
- Return 200 Success
unfollow {user}
Remove username from the list of users followed by the current user
Syntax:
unfollow {user} [{user} ...]
Actions:
- POST /network/unfollow
[ "{user1}", "{user2}", ...] - DELETE FROM connections WHERE followed_id=USER AND following_id=CURRENT
- DELETE FROM group_memberships WHERE user_id=USER AND group_id=groups.id AND groups.owner_id=CURRENT
- DELETE FROM user_sharing WHERE invited_user_id=USER AND owner_id=CURRENT
Examples
Examples:
> follow You are not following anyone > follow fred You are now following fred. > follow Following 1 user: fred > follow jim sheila You are now following jim, sheila > follow Following 3 users: fred jim sheila > unfollow jim You are no longer following jim > follow Following 2 users: jim sheila > unfollow jim sheila You are no longer following jim, sheila > follow You are not following anyone
Groups
Actions related to collecting the users you are following into groups
group
Report on the groups that have been created by the current user
Syntax:
group
Actions:
- GET /group/list/all
- SELECT * FROM groups;
- Return 200 [ '{group1}', {group2}', ...]
group {group}
Report on the members of the specified group
Syntax:
group {group}
Actions:
- GET /group/list/{group}
- SELECT * FROM group_memberships
group add
Add the specified user or users to a group, creating the group if it does not exist
Syntax:
group {group} --add {user} [{user} ...] group {group} -a {user} [{user} ...]
Actions:
- POST /group/add/{group}
[ "{user1}", "{user2}", ...] - If group name is on the disallowed list,
return 500 Disallowed - Create a list of USERs to add, and bail out if it's empty
- If {group} not not exist in SELECT {group} FROM groups WHERE owner_id=CURRENT AND name={group} then INSERT INTO groups (owner_id, name) VALUES (CURRENT, {group})
- For each USER in USERs: INSERT INTO group_memberships (group_id, user_id) VALUES (GROUP_ID, USER)
Illegal Group Names:
- everyone
- followers
- friends
- divert
- none
- all
- list
- add
- remove
group remove
Remove the specified user or users from a group, removing the group itself if this leaves it empty
Syntax:
group {group} --remove [{user} ...] group {group} -r [{user} ...]
Actions:
- POST /group/remove/{group}
[ "{user1}", "{user2}", ...] - Find the GROUP
- Create a list of USERs to remove
- If the list is empty
- DELETE FROM group_memberships WHERE group_id=GROUP AND user_id=CURRENT
- DELETE FORM groups WHERE group_id=GROUP
- Otherwise
- For each USER in USERs: DELETE FROM group_memberships WHERE group_id=GROUP AND user_id=CURRENT
- If 0 == SELECT COUNT(*) FROM group_memberships WHERE group_id=GROUP, then DELETE FORM groups WHERE group_id=GROUP
Project Sharing
List the sharing for the current user, optionally filtered by {project} and then optionally filtered by {user}
Syntax:
share [{project} [{user}|{group}|everyone]]
Actions:
- GET /share/{project}/{target}
- SELECT projects.name, sharing.type, users.name, sharing.loadany, sharing.edit FROM projects WHERE blah blah
- SELECT projects.name, sharing.type, groups.name, sharing.loadany, sharing.edit FROM projects WHERE blah blah
Change sharing options for a given project and user/group
Syntax:
share {project} ({user}|{group}|everyone) (none|readonly|edit) [loadany]
Actions:
- POST /share/{project}/{target}
[ "flag1", "flag2", ... ] - Check that CURRENT is the owner of PROJECT, you can't share others projects
- LOADANY=true for option loadany, false for myview or missing
- EDIT=true for option edit, false for readonly or missing
- If {target} is a {group}
- If {group}==everyone then skip the lookup of GROUP and use EVERYONE
- INSERT INTO group_sharing (owner_id, project_id, invited_group_id, loadany, edit) VALUES (CURRENT, PROJECT, GROUP, LOADANY, EDIT);
- If {target} is a {user}
- Check that USER is following CURRENT to prevent spam
- INSERT INTO user_sharing (owner_id, project_id, invited_user_id, loadany, edit) VALUES (CURRENT, PROJECT, USER, LOADANY, EDIT);
- If {flags} are none:
- DELETE FROM user_sharing WHERE owner_id=CURRENT AND project_id=PROJECT AND invited_user_id=USER
- If {group}==everyone then skip the lookup of GROUP and use EVERYONE
- DELETE FROM group_sharing WHERE owner_id=CURRENT AND project_id=PROJECT AND invited_user_id=GROUP
Remove all sharing of a project
Syntax:
share {project} none
Actions:
- POST /share/remove/{project}
- DELETE FROM user_sharing WHERE owner_id=CURRENT AND project_id=PROJECT
- DELETE FROM group_sharing WHERE owner_id=CURRENT AND project_id=PROJECT
Privacy
viewme {target}
Allows USER or GROUP to use the 'view' command on CURRENT
Syntax:
viewme ({user}|{group}|everyone) (true|false|default)
Actions:
- POST /viewme/{user}
{value} - Check that USER has already done 'follow current'
- UPDATE connections SET followed_viewable=FLAG WHERE followed_id=CURRENT AND following_id=USER
- Or
- UPDATE groups SET owner_viewable=FLAG WHERE owner_id=CURRENT AND name={group}
- Or
- UPDATE users SET everyone_viewable=FLAG WHERE id=CURRENT
viewme
Report on who has the ability to use the 'view' command on the current user
Syntax:
viewme
Actions:
- GET /viewme
- SELECT following_id FROM connections WHERE followed_viewable=true AND followed_id=CURRENT
- SELECT name FROM groups WHERE owner_viewable=true WHERE owner_id=CURRENT
- SELECT "everyone" IF users.everyone_viewable=true WHERE id=CURRENT
Interacting
view {user}
msg ({user}|{group}|everyone) {message}...
msg divert