( ctx context.Context, targetUserID, reason string, profileAPI userapi.ClientUserAPI, device *userapi.Device, membership, roomID string, isDirect bool, cfg *config.ClientAPI, evTime time.Time, rsAPI roomserverAPI.ClientRoomserverAPI, asAPI appserviceAPI.AppServiceInternalAPI, )
| 290 | } |
| 291 | |
| 292 | func buildMembershipEvent( |
| 293 | ctx context.Context, |
| 294 | targetUserID, reason string, profileAPI userapi.ClientUserAPI, |
| 295 | device *userapi.Device, |
| 296 | membership, roomID string, isDirect bool, |
| 297 | cfg *config.ClientAPI, evTime time.Time, |
| 298 | rsAPI roomserverAPI.ClientRoomserverAPI, asAPI appserviceAPI.AppServiceInternalAPI, |
| 299 | ) (*gomatrixserverlib.HeaderedEvent, error) { |
| 300 | profile, err := loadProfile(ctx, targetUserID, cfg, profileAPI, asAPI) |
| 301 | if err != nil { |
| 302 | return nil, err |
| 303 | } |
| 304 | |
| 305 | builder := gomatrixserverlib.EventBuilder{ |
| 306 | Sender: device.UserID, |
| 307 | RoomID: roomID, |
| 308 | Type: "m.room.member", |
| 309 | StateKey: &targetUserID, |
| 310 | } |
| 311 | |
| 312 | content := gomatrixserverlib.MemberContent{ |
| 313 | Membership: membership, |
| 314 | DisplayName: profile.DisplayName, |
| 315 | AvatarURL: profile.AvatarURL, |
| 316 | Reason: reason, |
| 317 | IsDirect: isDirect, |
| 318 | } |
| 319 | |
| 320 | if err = builder.SetContent(content); err != nil { |
| 321 | return nil, err |
| 322 | } |
| 323 | |
| 324 | return eventutil.QueryAndBuildEvent(ctx, &builder, cfg.Matrix, evTime, rsAPI, nil) |
| 325 | } |
| 326 | |
| 327 | // loadProfile lookups the profile of a given user from the database and returns |
| 328 | // it if the user is local to this server, or returns an empty profile if not. |
no test coverage detected