This commit is contained in:
Ulf Gebhardt 2025-04-01 23:33:56 +02:00
parent 21f9feb516
commit 1bb0b7fce9
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
5 changed files with 28 additions and 0 deletions

View File

@ -462,6 +462,7 @@ export default shield(
switchUserRole: isAdmin,
markTeaserAsViewed: allow,
saveCategorySettings: isAuthenticated,
updateOnlineStatus: isAuthenticated,
CreateRoom: isAuthenticated,
CreateMessage: isAuthenticated,
MarkMessagesAsSeen: isAuthenticated,

View File

@ -54,6 +54,7 @@ export default {
},
invitedBy: { type: 'relationship', relationship: 'INVITED', target: 'User', direction: 'in' },
lastActiveAt: { type: 'string', isoDate: true },
lastOnlineStatus: { type: 'string' },
createdAt: { type: 'string', isoDate: true, default: () => new Date().toISOString() },
updatedAt: {
type: 'string',

View File

@ -314,6 +314,26 @@ export default {
session.close()
}
},
updateOnlineStatus: async (object, args, context, resolveInfo) => {
const { status } = args
const {
user: { id },
} = context
// Last Online Time is saved as `lastActiveAt`
const session = context.driver.session()
await session.writeTransaction((transaction) => {
return transaction.run(
`
MATCH (user:User {id: $id})
SET user.lastOnlineStatus = $status
`,
{ id, status },
)
})
return true
},
},
User: {
email: async (parent, params, context, resolveInfo) => {

View File

@ -0,0 +1,4 @@
enum OnlineStatus {
online
away
}

View File

@ -224,6 +224,8 @@ type Mutation {
switchUserRole(role: UserRole!, id: ID!): User
saveCategorySettings(activeCategories: [String]): Boolean
updateOnlineStatus(status: OnlineStatus!): Boolean!
requestPasswordReset(email: String!): Boolean!
resetPassword(email: String!, nonce: String!, newPassword: String!): Boolean!