Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/copleykj/socialize-friendships

A Meteor package for creating friendship functionality within your app.
https://github.com/copleykj/socialize-friendships

friendships meteor redis-oplog scalability sponsor

Last synced: 4 months ago
JSON representation

A Meteor package for creating friendship functionality within your app.

Awesome Lists containing this project

README

        

# Friendships

Provides social network style Friend Requests and Friendships.

>>This is a [Meteor][meteor] package with part of it's code published as a companion NPM package made to work with clients other than Meteor. For example your server is Meteor, but you want to build a React Native app for the client. This allows you to share code between your Meteor server and other clients to give you a competitive advantage when bringing your mobile and web application to market.

- [Supporting The Project](#supporting-the-project)
- [Installation](#installation)
- [NPM Installation](#npm-installation)
- [Usage Outside Meteor](#usage-outside-meteor)
- [React Native](#react-native)
- [Basic Usage](#basic-usage)
- [Requests](#requests)
- [Blocking](#blocking)
- [Scalability - Redis Oplog](#scalability---redis-oplog)

## Supporting The Project

Finding the time to maintain FOSS projects can be quite difficult. I am myself responsible for over 30 personal projects across 2 platforms, as well as Multiple others maintained by the [Meteor Community Packages](https://github.com/meteor-community-packages) organization. Therfore, if you appreciate my work, I ask that you either sponsor my work through GitHub, or donate via Paypal or Patreon. Every dollar helps give cause for spending my free time fielding issues, feature requests, pull requests and releasing updates. Info can be found in the "Sponsor this project" section of the [GitHub Repo](https://github.com/copleykj/socialize-friendships)

## Installation

This package relies on the npm package `simpl-schema` so when using with Meteor, you will need to make sure it is installed as well.

```shell
meteor npm install --save simpl-schema
meteor add socialize:messaging
```

## NPM Installation

When using this package with React Native, the dependency tree ensures that `simpl-schema` is loaded so there's no need to install it as when using within Meteor.

```shell
npm install --save @socialize/user-friendships
```

## Usage Outside Meteor

The client side parts of this package are published to NPM as `@socialize/cloudinary` for use in front ends outside of Meteor.

When using the npm package you'll need to connect to a server, which hosts the server side Meteor code for your app, using `Meteor.connect` as per the [@socialize/react-native-meteor usage example](https://github.com/copleykj/react-native-meteor#example-usage) documentation.

```javascript
Meteor.connect('ws://192.168.X.X:3000/websocket');
```

### React Native

When using this package with React Native there is some minor setup required by the `@socialize/react-native-meteor` package. See [@socialize/react-native-meteor react-native](https://github.com/copleykj/react-native-meteor#react-native) for necessary instructions.

## Basic Usage

When using this package with React Native you will need to import the package to cause the user class to be properly extended. This way new instances of the `User` class returned from `Meteor.users` `find` and `findOne` methods as well as `Meteor.user()` will have this packages methods available on them.

```javascript
import '@socialize/friendships';
```

```javascript
Meteor.users.findOne({username:'copleykj'}).requestFriendship();

Meteor.users.findOne({username:'storytellercz'}).acceptFriendshipRequest();

Meteor.user().requests().fetch(); // fetch all the requests from other users
Meteor.user().pendingRequests().fetch() // fetch all requests to other users
```

For a more in depth explanation of how to use this package see [API.md](api)

## Requests

This package implements the [socialize:requestable][socialize-requestable] package to allow friendship requests between users

Requests are created by calling `user.requestFriendship` where `user` is an instance of the User class. The request will be created as a request from the currently logged in user to the user represented by `user`.

Other methods for retaining information about requests or interacting with requests pertaining to the current user are also available on the User class and are detailed in the [User Extensions](API.md/#user-extensions) section of [API.md][api].

## Blocking

This package also implements blocking of other users through the [socialize:user-blocking][socialize-user-blocking] package and will not allow requests from blocked users. Also if a user is blocked and the user is a friend at the time of blocking, the friendship will be severed as well. For more information about the user-blocking API, refer to it's package documentation.

## Scalability - Redis Oplog

This package implements [cultofcoders:redis-oplog][redis-oplog]'s namespaces to provide reactive scalability as an alternative to Meteor's `livedata`. Use of redis-oplog is not required and will not engage until you install the [cultofcoders:redis-oplog][redis-oplog] package and configure it.

[redis-oplog]:https://github.com/cultofcoders/redis-oplog
[socialize-requestable]:https://github.com/copleykj/socialize-requestable
[socialize-user-blocking]:https://github.com/copleykj/socialize-user-blocking
[socialize]: https://atmospherejs.com/socialize
[api]: https://github.com/copleykj/socialize-friendships/blob/master/API.md
[user-extensions]: https://github.com/copleykj/socialize-friendships/blob/master/API.md/#user-extensions
[meteor]: https://meteor.com