Skip to content

Commit

Permalink
Google/quick add (#4)
Browse files Browse the repository at this point in the history
* Login branch initial commit

* Basic Message Printing

* Login/Logout Api Call

* Resolved minor errors

* Improved url

* Changed response_type

* Added the auth link as the message

* Webhook Endpoint

* Changed workflow

* Corrected typo

* Add token id to app persistence

* Updated files

* Changed Webhook method

* Updated api call

* Access token received

* Included user credentials, success login message

* Added access token in app persistence and updated Readme

* Updated persistence

* Update README.md

* Logged access token inside GCGetter

* Added logout feature

* View Event call added

* Display title, start and end time of events

* Date - Time format changed

* Create event implemented

* Error message if event creation fails

* Added redirect uri config setting

* Added link with each view event for update/delete

* Update README.md

* Update README.md

* Resolved conflicts

* Create LICENSE

* Quickadd Added

* Changed naming convention

* Update README.md

* Update README.md

* Updated changes

* Updated persistence

* Fix typo on variable name

* Revert "Fix typo on variable name"

This reverts commit 6425639.

* Google/calendar list (#5)

* Fetching all calendars

* Added calendar buttons

* Calendars and buttons in single message

* Store preferred calendar in persistence

* Updated calendar list feature

* Update README.md

* Updated workflow

* Removed logs

* Updated

* Google/public (#11)

* Public events creation

* Changed string concatenation

* Creating Public events

* Update GSGetter.ts

* Update GSGetter.ts
  • Loading branch information
Gautime authored and d-gubert committed Aug 16, 2019
1 parent 908d72f commit 797f9fa
Show file tree
Hide file tree
Showing 8 changed files with 261 additions and 143 deletions.
14 changes: 2 additions & 12 deletions Commands/GCCommands.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { IHttp, IModify, IPersistence, IRead } from '@rocket.chat/apps-engine/definition/accessors';
import { ISlashCommand, ISlashCommandPreview, ISlashCommandPreviewItem, SlashCommandContext } from '@rocket.chat/apps-engine/definition/slashcommands';
import { GoogleCalendarApp } from '../GoogleCalendar';
import { GCGetter } from '../helpers/GSGetter';
import { ApiEndpoint, IApiEndpointInfo, IApiRequest, IApiResponse } from '@rocket.chat/apps-engine/definition/api';
import { AppPersistence } from '../helpers/persistence';
import { IUser } from '@rocket.chat/apps-engine/definition/users';



export class GCCommand implements ISlashCommand {

public command = 'calendar';
Expand All @@ -25,16 +22,9 @@ export class GCCommand implements ISlashCommand {
try {


const loginstatus = await this.app.getGCGetter().login(this.app.getLogger(), read, http, modify, context, persis);

msg.setText('Slashcommand executed');
// await modify.getCreator().finish(msg);
modify.getNotifier().notifyUser(context.getSender(), msg.getMessage());


const login_status = await this.app.getGCGetter().login(this.app.getLogger(), read, http, modify, context, persis);
} catch (e) {
this.app.getLogger().error('Failed sending login url', e);
//msg.setText('An error occurred when trying to send the login url:disappointed_relieved:');
this.app.getLogger().error('Failed executing slashcommand', e);
}

}
Expand Down
2 changes: 0 additions & 2 deletions GoogleCalendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export class GoogleCalendarApp extends App {
constructor(info: IAppInfo, logger: ILogger, accessors: IAppAccessors) {
super(info, logger, accessors);
this.gcGetter = new GCGetter();
//this.webhook= new WebhookEndpoint(this);

}
public getGCGetter(): GCGetter {
Expand Down Expand Up @@ -81,7 +80,6 @@ export class GoogleCalendarApp extends App {
i18nDescription: 'Customize_Redirect_URI',
});


await configuration.slashCommands.provideSlashCommand(new GCCommand(this));

}
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,18 @@ Integrates google calendar with your Rocket.Chat server.
* Authenticate to your gmail account from inside your Rocket.Chat.
* Create your private events in your google calendar fom your Rocket.Chat using just a slashcommand.
* View and update your private events using just a slashcommand.
* Create a quick event using *quickadd* slashcommand.
* View all the calendars present on your profile and can even select any one of those calendars to work with.
* Get reminders and notifications of events.
* Create public events inside a room inviting all the users inside the room.

## How to use it?
* Download or clone the repository to your local system.
* Get your local Rocket.Chat server running.
* Navigate inside the folder using terminal.
* Run command `rc-apps deploy --url http://localhost:3000 --username {your_username} --password {your_password}`
* This gets the app installed in your local server, now navigate to app screen inside Options -> Administration -> Apps -> Google Calendar
* Activate the app and put in the credentials and start using it inside any of your room!

## Quick Start Guide

Expand All @@ -21,7 +30,19 @@ Integrates google calendar with your Rocket.Chat server.

* `/calendar logout` : Once you are done with viewing, creating your calendar events and wants to log out of the gmail account, use this command and it will log you out and redirect to your home page.

* `/calendar view` : Once the authentication is successful, you can use this command to view the private events on your calendar. Events will be displayed with title, date, start time and end time. You will also get the link, which you can click on and it will take directly to your calendar where you can udpate or delete that event.

* `/calendar create "Title" "Date" "Start time" "Endtime"` : This command can be used to create a private on your primary calendar, where Title is the title of the event you are creating, and date should be in format YYYY-MM-DD and time in 24 hours format.

* `/calendar logout` : Once you are done with viewing, creating your calendar events and wants to log out of the gmail account, use this command and it will log you out and redirect to your home page.

* `/calendar quickadd {title of the event}` - This slashcommand can be used to create an event starting from time the slashcommand is called to one hour in duration.

* `/calendar list` - Shows you the list of the calendars that are present on your user profile. For each calendar there is a button, which you can click and decide which calendar to communicate with and that calendar will be used for fetching and editing events (though this is optional, Google Calendar app uses your primary calendar by default.)

* `/calendar invite "Title" "Date" "Starttime" "Endtime" ` - This slashcommand will create public events which will include inviting all the users present inside the room (in which command is called) to this event. All the users will receive the event invite through e-mails. They can respond to that invite and the organizer will receive their response notifications via e-mails.

### Feedback and Suggestions
Contribute to this repository by opening an issue if you have any feedback or suggestions for improvements or even some feature request!


8 changes: 4 additions & 4 deletions helpers/GCResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ import { HttpStatusCode, IHttp, ILogger, IRead } from '@rocket.chat/apps-engine/
import { IApiRequest } from '@rocket.chat/apps-engine/definition/api';

export class GCResults {
public atoken: string;
public acess_token: string;

constructor(data?: any) {

if (data) {
this.atoken = data.access_token as string;
this.acess_token = data.access_token as string;
}
}

public result(): string {
if (!this.atoken) {
if (!this.acess_token) {
throw new Error('Invalid result');
}
return this.atoken;
return this.acess_token;
}

}
Loading

0 comments on commit 797f9fa

Please sign in to comment.