Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/pieces/community/date-helper/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@activepieces/piece-date-helper",
"version": "0.1.19"
"version": "0.1.20"
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,12 @@ function addSubtractTime(date: Date, expression: string, timeZone?: string): day
let dayjsDate = timeZone ? apDayjs(date).tz(timeZone) : apDayjs(date);

for (let i = 0; i < numbers.length; i++) {
const val = units[i].toLowerCase() as timeParts;
switch (val) {
let val = units[i].toLowerCase();
if (val.endsWith('s')) {
val = val.slice(0, -1);
}
const normalizedVal = val as timeParts;
switch (normalizedVal) {
case timeParts.year:
dayjsDate = dayjsDate.add(numbers[i], 'year');
break;
Expand All @@ -189,8 +193,7 @@ function addSubtractTime(date: Date, expression: string, timeZone?: string): day
case timeParts.unix_time:
break;
default: {
const nvr: never = val;
console.error(nvr, 'unhandled case was reached');
console.error(val, 'unhandled case was reached');
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/pieces/community/microsoft-teams/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-microsoft-teams",
"version": "0.3.0",
"version": "0.3.1",
"dependencies": {
"@microsoft/microsoft-graph-client": "3.0.7",
"@microsoft/microsoft-graph-types": "2.40.0"
Expand Down
2 changes: 2 additions & 0 deletions packages/pieces/community/microsoft-teams/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { getChannelMessageAction } from './lib/actions/get-channel-message';
import { findChannelAction } from './lib/actions/find-channel';
import { findTeamMemberAction } from './lib/actions/find-team-member';
import { createGraphClient, withGraphRetry } from './lib/common/graph';
import { deleteChatMessageAction } from './lib/actions/delete-chat-message';

const authDesc = `
1. Sign in to [Microsoft Azure Portal](https://portal.azure.com/).
Expand Down Expand Up @@ -109,6 +110,7 @@ export const microsoftTeams = createPiece({
createChatAndSendMessageAction,
createPrivateChannelAction,
getChatMessageAction,
deleteChatMessageAction,
getChannelMessageAction,
findChannelAction,
findTeamMemberAction,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { microsoftTeamsAuth } from '../../';
import { createAction, Property } from '@activepieces/pieces-framework';
import { microsoftTeamsCommon } from '../common';
import { Client } from '@microsoft/microsoft-graph-client';

export const deleteChatMessageAction = createAction({
auth: microsoftTeamsAuth,
name: 'microsoft_teams_delete_chat_message',
displayName: 'Delete Chat Message',
description: 'Soft-Deletes a message in chat.You can only delete messages you sent.',
props: {
chatId: microsoftTeamsCommon.chatId,
messageId: Property.ShortText({
displayName: 'Message ID',
required: true,
description: 'The ID of the message to delete.',
}),
},
async run(context) {
const { chatId, messageId } = context.propsValue;

const client = Client.initWithMiddleware({
authProvider: {
getAccessToken: () => Promise.resolve(context.auth.access_token),
},
});


const me = await client.api('/me').select('id,userPrincipalName').get();

await client.api(`/users/${me.id}/chats/${chatId}/messages/${messageId}/softDelete`).post({});

return {success:true,messageId,chatId}


},
});


Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import { securityAccess } from '@activepieces/server-shared'
import { ApEdition, TemplateTelemetryEvent } from '@activepieces/shared'
import { TemplateTelemetryEvent } from '@activepieces/shared'
import { FastifyPluginAsyncTypebox } from '@fastify/type-provider-typebox'
import { StatusCodes } from 'http-status-codes'
import { system } from '../../helper/system/system'
import { templateTelemetryService } from './template-telemetry.service'

const edition = system.getEdition()

export const templateTelemetryController: FastifyPluginAsyncTypebox = async (app) => {
app.post('/event', SendEventParams, async (request, reply) => {
if (edition !== ApEdition.CLOUD) {
return reply.status(StatusCodes.OK).send()
}
templateTelemetryService(app.log).sendEvent(request.body)
return reply.status(StatusCodes.OK).send()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FastifyBaseLogger } from 'fastify'
import { system } from '../../helper/system/system'

const CLOUD_TELEMETRY_URL = 'https://cloud.activepieces.com/api/v1/templates-telemetry'
const INTERNAL_TELEMETRY_URL = 'https://template-manager.activepieces.com/api/public/analytics'
const INTERNAL_TELEMETRY_URL = 'https://template-manager.activepieces.com/api/public/analytics/event'
const TEMPLATE_TELEMETRY_API_KEY = system.get(AppSystemProp.TEMPLATE_MANAGER_API_KEY)
const TEMPLATE_TELEMETRY_API_KEY_HEADER = 'X-API-Key'

Expand Down Expand Up @@ -61,27 +61,13 @@ async function sendToInternal(event: TemplateTelemetryEvent, log: FastifyBaseLog
function getEventConfig(event: TemplateTelemetryEvent): { url: string, body?: Record<string, unknown> } {
switch (event.eventType) {
case TemplateTelemetryEventType.VIEW:
return {
url: `${INTERNAL_TELEMETRY_URL}/templates/${event.templateId}/view`,
}
case TemplateTelemetryEventType.INSTALL:
return {
url: `${INTERNAL_TELEMETRY_URL}/templates/${event.templateId}/install`,
body: event,
}
case TemplateTelemetryEventType.ACTIVATE:
return {
url: `${INTERNAL_TELEMETRY_URL}/templates/${event.templateId}/activate`,
body: event,
}
case TemplateTelemetryEventType.DEACTIVATE:
return {
url: `${INTERNAL_TELEMETRY_URL}/templates/${event.templateId}/deactivate`,
body: event,
}
case TemplateTelemetryEventType.EXPLORE_VIEW:
return {
url: `${INTERNAL_TELEMETRY_URL}/explore/view`,
url: INTERNAL_TELEMETRY_URL,
body: event,
}
default:
throw new Error(`Unknown template telemetry event type: ${(event as { eventType: string }).eventType}`)
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/lib/template/template-telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const DeactivateEvent = Type.Object({

const ExploreViewEvent = Type.Object({
eventType: Type.Literal(TemplateTelemetryEventType.EXPLORE_VIEW),
userId: Type.Optional(Type.String()),
})

export const TemplateTelemetryEvent = Type.Union([
Expand Down
Loading