Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
The sharepoint list now defines how many days in ahead we should disp…
Browse files Browse the repository at this point in the history
…lay events for. Defaults to 7 days.
  • Loading branch information
MatsAnd committed Sep 21, 2020
1 parent 504ec46 commit 098ef8c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/get-user-event-tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = async (context, token, graphUser) => {
context.log('user tabs', userTabs)

const tabEvents = await Promise.all(userTabs.map(async tab => {
const events = await getGraphEvents(context, token, userPrincipalName, tab.CalendarUrl)
const events = await getGraphEvents(context, token, userPrincipalName, tab.CalendarUrl, tab.DaysAhead)
if (!events) {
context.log.error(['events', userPrincipalName, 'err', `No events found for: ${tab.CalendarUrl}`])
return null // will be filtered out later
Expand Down
4 changes: 2 additions & 2 deletions lib/graph/get-graph-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const axios = require('axios').default
const getGraphToken = require('./get-graph-token')
const { graph: { user, events } } = require('../../config')

module.exports = async (context, token, userPrincipalName, graphUserUrl) => {
module.exports = async (context, token, userPrincipalName, graphUserUrl, daysAhead = 7) => {
if (!token) {
// If no token is provided - gather application graph token
context.log(['events', 'get-graph-events', userPrincipalName, 'get-graph-token'])
Expand All @@ -19,7 +19,7 @@ module.exports = async (context, token, userPrincipalName, graphUserUrl) => {

const now = new Date()
const oneWeek = new Date()
oneWeek.setDate(oneWeek.getDate() + 7)
oneWeek.setDate(oneWeek.getDate() + (isNaN(daysAhead) ? 7 : parseInt(daysAhead.toString())))

const { data } = await axios({
url: graphUrl,
Expand Down
3 changes: 2 additions & 1 deletion lib/graph/sharepoint/repack-sharepoint-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = ({ id, fields }) => {
TabName: fields.Title,
GroupID: fields.GroupID,
CalendarUrl: fields.CalendarGraphURL,
SortOrder: fields.Sortorder
SortOrder: fields.Sortorder,
DaysAhead: fields.DaysAhead
}
}

0 comments on commit 098ef8c

Please # to comment.