2.7.5 • Published 7 years ago

lurchr-api v2.7.5

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

lurchr-api

API module for lurchr that mostly just handles the database layer.

Usage

const api = require('lurchr-api')();

api.teams.get('T123123', function (err, team) {
  if (err) throw err;

  console.log(team);
});

Methods

api.teams.upsert(teamId, team, cb)

Upserts a team.

api.teams.get(teamId, cb)

Returns a team or null.

api.teams.getByDomain(domain, cb)

Returns a team from a domain name.

api.teams.allActive(cb)

Returns all active teams.

api.teams.all(cb)

Returns all teams on lurchr.

api.teams.getNotBackfilled(cb)

Returns one team that have not been initialized.

Sets a lock for 15 minutes. If needed refresh the lock by using refreshLock

api.teams.refreshLock(teamId, cb)

Sets the lock for a team for 15 minutes.

api.users.upsert(teamId, userId, user, cb)

Upserts a user in a team.

api.users.upsertMany(teamId, users, cb)

Upserts many users. Each user should have an id property set.

api.users.get(teamId, userId, cb)

Returns a user in a team.

api.users.getByName(teamId, name, cb)

Returns a user by using the username.

api.users.all(teamId, cb)

Returns all users in a team.

api.channels.upsert(teamId, channelId, channel, cb)

Upserts a channel in a team.

api.channels.upsertMany(teamId, channels, cb)

Upserts many channels. Each channel should have an id property set.

api.channels.get(teamId, channelId, cb)

Returns a channel in a team.

api.channels.all(teamId, cb)

Returns all channels in a team.

api.channels.addUser(teamId, channelId, userId, cb)

Adds a user to a channel's members list.

api.channels.removeUser(teamId, channelId, userId, cb)

Removes a user from a channel's members list.

api.emojis.upsert(teamId, emojiId, emoji, cb)

Upserts an emoji in a team.

api.emojis.upsertMany(teamId, emojis, cb)

Upsert many emojis in a team. Each emoji should have an id property set.

api.emojis.get(teamId, emojiId, cb)

Return the url/alias to the given emoji.

api.emojis.deleteMany(teamId, emojis, cb)

Deletes many emojis in a team. emojis should just be an array with emojiID's.

api.links.upsert(teamId, linkId, link, cb)

Upserts a link in a team.

api.links.get(teamId, linkId, cb)

Returns a link from a given id.

api.links.search(teamId, options, cb)

Performs a search. Options can be many different things. All can be combined.

  • options.size Number of results. Defaults to 20.
  • options.skip Number of results to skip. Defaults to 0.
  • options.channels Channel ID's to limit to
  • options.users User ID's to limit to
  • options.links Link ID's to limit to
  • options.fromDate A UNIX timestamp to limit to
  • options.toDate A UNIX timestamp to limit to
  • options.text Perform a full-text search on description, title, and partly the page content

api.links.markAsRead(teamId, userId, linkId, cb)

Add the userId to .read[] and remove from .unread[].

api.links.markAsUnread(teamId, userId, linkId, cb)

Add the userId to .unread[] and remove from .read[].

api.links.markChannelAsRead(teamId, channelId, userId, cb)

Add the userId to .read[] in all links with the channelId.

api.links.all(teamId, cb)

Get all links for a team.

api.links.getUnreadCountByChannel(teamId, channelId, userId, cb)

Return the number of links the userId haven read in channelId.

api.links.initUnreadStatus(teamId, linkId, ts, cb)

First checks to see if ts is less than 7 days old. If not it's ignored.

Adds all registered user on teamId to .unread[] on linkId

api.links.initUserUnreadStatus(teamId, userId, cb)

Inits a user by going through all links on the team, and adds the user to .unread[].

All links less than 7 days old or posted by userId is ignored.

api.stars.add(teamId, userId, linkId, cb)

Adds userId to linkId's .starred[].

api.stars.remove(teamId, userId, linkId, cb)

Removes userId from linkId's .starred[].

api.stars.all(teamId, userId, cb)

Returns an array of link ID's that the userId have starred.

2.7.5

7 years ago

2.7.4

7 years ago